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

Elements in disconnected shadow roots should still be readable with ShadowRoot.getElementById #34740

Closed
jdm opened this issue Dec 22, 2024 · 1 comment · Fixed by #34803
Closed
Labels
A-content/dom Interacting with the DOM from web content E-more-complex Variable effort required; may require a mentor. Recommended solution is clearly described in the iss

Comments

@jdm
Copy link
Member

jdm commented Dec 22, 2024

Test: tests/wpt/tests/shadow-dom/getElementById-dynamic-001.html
Spec: https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid

I suspect we need to make the logic in these methods more complicated than it currently is:

@jdm jdm added A-content/dom Interacting with the DOM from web content E-more-complex Variable effort required; may require a mentor. Recommended solution is clearly described in the iss labels Dec 22, 2024
@simonwuelker
Copy link
Contributor

simonwuelker commented Dec 29, 2024

The issue here is similar to what i described in #34787 (comment).

The test removes a element that is a shadow root from a document. A descendant of said element has it's unbind_from_tree method called, which incorrectly assumes that it is being disconnected from it's shadow host (which it is still attached to) and unregisters itself.

if let Some(ref value) = *self.id_attribute.borrow() {
if let Some(ref shadow_root) = self.upcast::<Node>().containing_shadow_root() {
shadow_root.unregister_element_id(self, value.clone());
} else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/dom Interacting with the DOM from web content E-more-complex Variable effort required; may require a mentor. Recommended solution is clearly described in the iss
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants