When an AMP page utilizing amp-geo is loaded into a PWA, the classes created by amp-geo (e.g. amp-geo-group-____
and amp-iso-country-__
) are appended to the appshell body instead of the AMP document body. Since styles are encapsulated in a shadow document, these classes are unavailable for styling elements in the AMP document.
I have created a minimal example that demonstrates the issue. The AMP document has styles defined to show the message _This message is visible if any amp-geo class is added to the body._ if any amp-geo
class is attached to the body. If no amp-geo
class is attached, then the message _No amp-geo class is attached to the body._ appears.
The AMP page shows _This message is visible if any amp-geo class is added to the body._
The AMP page viewed in the PWA shows _No amp-geo class is attached to the body._
The following browsers have been tested and both exhibit the same behavior:
1902081532110
cc @jpettitt @zhouyx @prateekbh ? Don't quite know who would be the owner on this, my apologies.
I can take this. can reproduce, will take a look soon.
FYI @torch2424 the primary owner of amp-geo
is now @zhouyx
@zhouyx thoughts/questions:
body
elements? (appshell and AMP document?)amp-experiment
comes to mind ?) that might have similar issues?Thank you @jpettitt. First thought I believe the class should be added to only the AMP document as amp-geo itself is a document level service. And as @mattwomple pointed out styles are encapsulated in a shadow document.
It's a great point that amp-experiment is another similar extension that applies class to body, I'll definitely see what can be done there as well.
Thanks @jpettitt 馃槃
Found why, amp-geo tries to add classList to the window.document instead of the ampdoc.rootNode. I'll work on the fix next week.
I've also tested the amp-experiment behavior. It is working as expected and I can verify amp-experiment is apply change to the ampdoc.rootnode, which points to the shadowRoot or document in different environment.
@zhouyx @jpettitt If one or both of you would be willing to review #21282 it would be appreciated. Thanks.
Done, I'll merge it once the tests complete.
Thank you for the quick attention and review @jpettitt
Fix is merged, it should hit the canary/dev channel build next week and prod the week after. @mattwomple please check it when it hits canary (typically late Tuesday California time)
@jpettitt I tested build 1903080058260 today and this change is working as expected. Thanks.
Most helpful comment
FYI @torch2424 the primary owner of
amp-geo
is now @zhouyx