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

[bug] Non-gated IntersectionObserver polyfill breaks the whole polyfill bundle #458

Closed
okovpashko opened this issue Feb 9, 2020 · 2 comments

Comments

@okovpashko
Copy link

What

There's a script error when adding IntersectionObserver polyfill with always and without gated flag: https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver&flags=always

Details

I found the issue in Safari 9, 10, 11 that don't have IntersectionObserver when I was trying to force adding a polyfill with the manual feature detection. The issue is reproduced in the latest Chrome and Firefox as well.

Safari:

HierarchyRequestError: The operation would yield an incorrect node tree.

Chrome:

Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.

The error seems to be caused by the Element polyfill that's trying to create body DOM element and append it to the existing document here.
I'm not 100% sure that this code is invalid and maybe it's a kind of tweak for the old browsers but two body tags in the same document look strange and relatively modern browsers complain about it.

Here is a minimal example. See console output in the browser's DevTools.

@JakeChampion
Copy link
Owner

Yes, this is to be expected behavior. The always flag will load all requested polyfills and all their dependent polyfills. You can work around this by adding Element|gated to your features parameter to load Element polyfill in a feature detect.

I will also fix this by inlining a feature detect into Element polyfill -- #481

Origami ✨ automation moved this from incoming to complete Feb 24, 2020
@okovpashko
Copy link
Author

okovpashko commented Mar 28, 2020

@JakeChampion thanks for the answer and for the fix.
Is this correct at all to add the second body element to the document? It looks like a kind of magic for the very old browsers.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2020
@robertboulton robertboulton removed this from Done in Origami ✨ Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants