Prevent PWA bugs due to A4A's getCorrelator()#16233
Merged
dreamofabear merged 4 commits intoampproject:masterfrom Jun 22, 2018
Merged
Prevent PWA bugs due to A4A's getCorrelator()#16233dreamofabear merged 4 commits intoampproject:masterfrom
dreamofabear merged 4 commits intoampproject:masterfrom
Conversation
added 2 commits
June 21, 2018 19:02
keithwrightbos
approved these changes
Jun 22, 2018
Contributor
keithwrightbos
left a comment
There was a problem hiding this comment.
Ideally we would have some functional test that loads an amp-ad within a shadow root
Author
You can use amphtml/extensions/amp-bind/0.1/test/integration/test-bind-impl.js Lines 203 to 207 in 4e6cd91 |
Member
|
My local setup doesn't reproduce the error because of the localhost-specific logic, so patching this locally won't help diagnose the problem :( |
Author
|
Ah ok, I thought the experiment was the cause of the local repro failure. Keith just removed that entire code path so I think the bug will be fixed either way. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think this fixes #16043.
The root problem is that
getServiceForDoc(window.document)doesn't work in PWAs. This is because it relies onAmpDocService#getAmpDoc(node)which traverses upnode's parents to find the service holder. However, in shadow AMP services live on the shadow root, which is a child of the document. So traversing up the document will fail to find the shadow root.Instead, non-window service getters should always be passed the AMP element itself (or a nearby node), e.g.
getServiceForDoc(myAmpElement). We have a long-standing initiative to refactor and improve this but it hasn't been prioritized yet (go/amp-roots)./to @keithwrightbos For code review.
/to @danielrozenberg Can you try patching this into your local repro setup?