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

🐛 Upgrade shadow root contents when defining new CEs #25337

Merged
merged 3 commits into from
Oct 30, 2019

Conversation

jridgewell
Copy link
Contributor

When we've already initialized the the custom element registry, it used to drop the list of shadow roots. When a new CE was defined, we would then only query the host document (since we dropped all the shadow roots from the array). Obviously, that query selector won't find CEs inside the shadow tree.

So, we need to keep the list of shadow roots, that way we can query inside them when defining new custom elements.

Note, this will mean leaking every shadow permanently. Even if the shadow's host is removed from the document, we'll still have to keep its reference. We could setup a long running interval to find disconnected trees, but it wouldn't be able to tell the difference between a temporarily disconnected shadow and a destroyed shadow.

Fixes #25332

When we've already initialized the the custom element registry, it used to drop the list of shadow roots. When a new CE was defined, we would then only query the host `document` (since we dropped all the shadow roots from the array). Obviously, that query selector won't find CEs inside the shadow tree.

So, we need to keep the list of shadow roots, that way we can query inside them when defining new custom elements.

Note, this will mean leaking every shadow permenantly. Even if the shadow's host is removed from the document, we'll still have to keep its reference. We could setup a long running interval to find disconnected trees, but it wouldn't be able to tell the difference between a temporarily disconneded shadow and a destoyed shadow.
@mattwomple
Copy link
Member

Thanks @jridgewell . This seems reasonable for a cherry-pick.

Re: "I would love to not have to hold onto all of the roots"
As a minor improvement in the future, could we remove dead roots from the array when shadowAmp.close() is called?

@jridgewell jridgewell merged commit 476b89d into master Oct 30, 2019
jridgewell added a commit that referenced this pull request Oct 30, 2019
* Upgrade shadow root contents when defining new CEs

When we've already initialized the the custom element registry, it used to drop the list of shadow roots. When a new CE was defined, we would then only query the host `document` (since we dropped all the shadow roots from the array). Obviously, that query selector won't find CEs inside the shadow tree.

So, we need to keep the list of shadow roots, that way we can query inside them when defining new custom elements.

Note, this will mean leaking every shadow permenantly. Even if the shadow's host is removed from the document, we'll still have to keep its reference. We could setup a long running interval to find disconnected trees, but it wouldn't be able to tell the difference between a temporarily disconneded shadow and a destoyed shadow.

* Fix comment

* Remove unused private
jridgewell added a commit that referenced this pull request Oct 30, 2019
* Upgrade shadow root contents when defining new CEs

When we've already initialized the the custom element registry, it used to drop the list of shadow roots. When a new CE was defined, we would then only query the host `document` (since we dropped all the shadow roots from the array). Obviously, that query selector won't find CEs inside the shadow tree.

So, we need to keep the list of shadow roots, that way we can query inside them when defining new custom elements.

Note, this will mean leaking every shadow permenantly. Even if the shadow's host is removed from the document, we'll still have to keep its reference. We could setup a long running interval to find disconnected trees, but it wouldn't be able to tell the difference between a temporarily disconneded shadow and a destoyed shadow.

* Fix comment

* Remove unused private
@newmuis newmuis mentioned this pull request Oct 31, 2019
micajuine-ho pushed a commit to micajuine-ho/amphtml that referenced this pull request Dec 27, 2019
* Upgrade shadow root contents when defining new CEs

When we've already initialized the the custom element registry, it used to drop the list of shadow roots. When a new CE was defined, we would then only query the host `document` (since we dropped all the shadow roots from the array). Obviously, that query selector won't find CEs inside the shadow tree.

So, we need to keep the list of shadow roots, that way we can query inside them when defining new custom elements.

Note, this will mean leaking every shadow permenantly. Even if the shadow's host is removed from the document, we'll still have to keep its reference. We could setup a long running interval to find disconnected trees, but it wouldn't be able to tell the difference between a temporarily disconneded shadow and a destoyed shadow.

* Fix comment

* Remove unused private
@rsimha rsimha deleted the custom-elements-shadow branch February 13, 2020 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

amp-bind fails to initialize in PWA
3 participants