-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Universal IntersectionObserver polyfill #27595
Conversation
extensions/amp-intersection-observer-polyfill/0.1/amp-intersection-observer-polyfill.js
Outdated
Show resolved
Hide resolved
For the module build, can we ensure this polyfill is only loaded if the user-agent doesn't support |
We're loading the polyfill if needed in both modes. Note that module builds need it, too: https://prateekbh.lib.id/caniesmodule/?feature=intersectionobserver |
The vast majority of module browsers have support for |
That's what we're doing, for both modes. |
Missed that when reviewing, thanks for the confirmation. |
IMHO, |
Heads up. This is slightly blocked by w3c/IntersectionObserver#419. But review is in progress and I expect it to be completed soon. |
@erwinmombay @jridgewell PTAL, I added the actual polyfill, including rewriting the installer for controlled installation. |
extensions/amp-intersection-observer-polyfill/0.1/amp-intersection-observer-polyfill.js
Outdated
Show resolved
Hide resolved
@jridgewell ptal again. |
Upgraded to polyfill 0.8.0 that supports same-origin iframes (FIE). |
All. This is now ready for review. |
@zhouyx PTAL again. |
@danielrozenberg Do I just approve this? Shouldn't Dima have approval ability? I can't even tell why it's complaining, it looks like the check ran, but I can't tell what change it doesn't like |
@rcebulko it's possible that you were added for a bundle-size bot failure on a previous commit, and the force-push caused the check to run again, successfully this time. The PR author can't approve their own bundle-size change though, so someone else from the two listed teams needs to approve this PR again |
@rcebulko I'll take you off the review here. I think the reason you were added has been already resolved. |
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.
Just some readability suggestions. Curious to try this with "intersect-resources" experiment.
*/ | ||
|
||
/** | ||
* @fileoverview |
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.
Does this need to be a separate file from src/polyfills/intersection-observer.js? Following the code flow between the three files is a bit confusing.
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.
It is a bit confusing, I agree. I did this because otherwise src/polyfills
are removed from compiler in many cases. I'd have to instead add a lot of overrides for js and mjs. And I figured that would be more dangerous rather than having a clear line between stubs and polyfill installers. But lmk if you think it'd still be better to live with exceptions.
extensions/amp-intersection-observer-polyfill/0.1/amp-intersection-observer-polyfill.js
Outdated
Show resolved
Hide resolved
extensions/amp-intersection-observer-polyfill/0.1/amp-intersection-observer-polyfill.js
Outdated
Show resolved
Hide resolved
/** | ||
* @param {!Window} win | ||
*/ | ||
export function install(win) { |
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 think the word "install" is used to mean "stub", "fetch" and "upgrade" in different places which is tough for readability. Can we call this stub
?
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 renamed all others to upgrade
per your suggestions above. But I'd rather keep calling this one install()
b/c I think this hides the fact of stubbing from most of places as an implementation choice. But I also redid the "fetch" part as well to reduce number of entities. PTAL.
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.
build-system/
changes LGTM.
This experiment breaks releases, I created #27937 to revert the experiment config (none of the other files are being reverted) |
Partial for: #27807
This is a two-stage polyfill. It uses the asynchronous nature of IntersectionObserver API:
TODO: