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.
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
✨ Visibility trigger support for querySelectorAll #26886
✨ Visibility trigger support for querySelectorAll #26886
Changes from 17 commits
db28aad
7ba9784
74eaef3
926e4bf
cbdb344
1003500
62ab379
beb8f58
7a43664
df942d2
7456e8d
813992f
7683e34
e9efdfe
b4228b8
97c92a9
c4b9cc5
2108ac7
b6ea443
71c6b80
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this goes into
getElementsByQuerySelectorAll_
as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't make a much of a difference when the elements list is small, but it does take O(n^2) time... I'm a bit concerned when one try to select every single
<p>
of a document. could you please bench mark the performance with a reasonable element count? Thanks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a webpage with 30 amp-ad elements and no throttle:
Not sure if there's. better way to do O(n)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm, what will be the API provided after all changes.
analyticsRoot.getElements()
andanalyticsRoot.getElement()
or a single
analyticsRoot.getElements()
or anything?The design would affect tests here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will have
analyticsRoot.getElements()
(added in this pr) andanalyticsRoot.getElement()
, previous tests covergetElement()
.Adding test coverage for
getElements(Array<string>|string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we deprecate usage of
analyticsRoot.getElement()
afterwards? If so is the plan to fix related test in the following PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
getElement()
is still used bygetAmpElement()
which is staying (non-experiment case).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you try one thing, add another element to the embed host and make sure it won't be selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping on this comment : )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhouyx Do you mean add another element that is non-amp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant add element with the className to the env.parentWin and then verify that they don't get selected.
https://github.com/ampproject/amphtml/blob/master/testing/describes.js#L805
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Thanks for the explanation. Added an element called parentChild that is attached to the the parentWin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks