Fix IS_IN_SHADOW_TREE flag for descendants after Node::remove call (#34803)

* Consider a UnbindContext to be tree-connected if its in a shadow root

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Properly track whether a node is in a shadow tree after removing subtree

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-01-04 00:27:43 +01:00 committed by GitHub
parent e8f75c9aea
commit 1ab55e6b11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 15 deletions

View file

@ -3665,7 +3665,11 @@ impl VirtualMethods for Element {
}
if let Some(ref value) = *self.id_attribute.borrow() {
if let Some(ref shadow_root) = self.containing_shadow_root() {
shadow_root.unregister_element_id(self, value.clone());
// Only unregister the element id if the node was disconnected from it's shadow root
// (as opposed to the whole shadow tree being disconnected as a whole)
if !self.upcast::<Node>().is_in_shadow_tree() {
shadow_root.unregister_element_id(self, value.clone());
}
} else {
doc.unregister_element_id(self, value.clone());
}