Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[amp-story-player] Add ShadowDOM fallback for edge #30254

Merged
merged 4 commits into from
Sep 23, 2020

Conversation

Enriqe
Copy link
Contributor

@Enriqe Enriqe commented Sep 16, 2020

Closes #27358

Adds a fallback for older Edge browsers that don't support attachShadow by using the player element as container instead of a shadow root.

It also resets the width/height of the <a>, so that it doesn't push the stories below when using the player element as a container.

Copy link
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have some styles that will be problematic in amp-story-player-iframe.css:

  • :host will not target anything, should we create another containerToUse div and apply the same properties?
  • you set some CSS properties using the main selector, which will cause CSS collisions with non amp-story-player DOM
  • same for the iframe:nth-of-type(n) selectors

@@ -33,6 +33,12 @@ amp-story-player a:not(:first-of-type) {
visibility: hidden;
}

amp-story-player.i-amphtml-story-player-loaded a:first-of-type {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this does and why it is needed in this PR? If you're trying to hide the links, should we just display: none;? Also, why is this not an issue when Shadow DOM is supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, but when there's no shadow root inside the amp-story-player, the <a> tags get inherited size from the parent element: (see computed size)

image

Compare when there's a shadow DOM as sibling of the <a> tags:

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an issue, don't the stories iframe cover it?

Copy link
Contributor Author

@Enriqe Enriqe Sep 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, when the <a> tags get a size they get pushed under the iframe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, let's make sure the iframe container covers whatever is inside the tag by using a position absolute :))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline: when swiping in the last story, the <a> tag and whatever is inside of it will be visible. We think it's better to just hide it.

Copy link
Contributor

@gmajoulet gmajoulet Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we only hiding the first one though? Shouldn't we hide all the content within the amp-story-player tag, even if publishers add an <img> or a <p> or multiple <a>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for now we only hide the first one because the player explicitly sets styles on it to display the poster image while the story loads. But we can't know for sure what publisher does inside of it. Maybe we could do a
amp-story-player > *{ display:none } amp-story-player > .main-container { display:block }. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amp-story-player.loaded > *{ display:none } yes :))
You'd need to test it with and without shadow DOM.
You have more context but from what I know it sounds safer?

Copy link
Contributor Author

@Enriqe Enriqe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the useful comments!

:host will not target anything, should we create another containerToUse div and apply the same properties?

I just deleted the :host rules cause we weren't actually using them.

you set some CSS properties using the main selector, which will cause CSS collisions with non amp-story-player DOM
same for the iframe:nth-of-type(n) selectors

Good call. I made all of these be specific to children inside .amp-story-player-main-container. Which will be the container in both cases (shadow DOM or not).

@@ -33,6 +33,12 @@ amp-story-player a:not(:first-of-type) {
visibility: hidden;
}

amp-story-player.i-amphtml-story-player-loaded a:first-of-type {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, but when there's no shadow root inside the amp-story-player, the <a> tags get inherited size from the parent element: (see computed size)

image

Compare when there's a shadow DOM as sibling of the <a> tags:

image

@@ -33,6 +33,12 @@ amp-story-player a:not(:first-of-type) {
visibility: hidden;
}

amp-story-player.i-amphtml-story-player-loaded a:first-of-type {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an issue, don't the stories iframe cover it?

@Enriqe Enriqe merged commit f31bb10 into ampproject:master Sep 23, 2020
ed-bird pushed a commit to ed-bird/amphtml that referenced this pull request Dec 10, 2020
* fallback for edge

* tweak css

* fix specificity, use display none

* rename CSS class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

amp-story-player not working on old Edge browser
3 participants