mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Don't register unconnected shadow roots with their owner document (#34361)
* Don't falsely register Shadow Roots as connected Previously, a shadowroot would be registered as connected during the shadow hosts bind_to_tree call, even if the host was being bound to an element that was not itself connected to a document. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Move bind/unbind methods into a VirtualMethod impl Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add DocumentFragment/Shadowroot to vtable_for 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:
parent
888a93af47
commit
f1e89c58a6
10 changed files with 161 additions and 27 deletions
|
@ -552,9 +552,11 @@ impl Element {
|
|||
.upcast::<Node>()
|
||||
.set_containing_shadow_root(Some(&shadow_root));
|
||||
|
||||
if self.is_connected() {
|
||||
self.node.owner_doc().register_shadow_root(&shadow_root);
|
||||
}
|
||||
let bind_context = BindContext {
|
||||
tree_connected: self.upcast::<Node>().is_connected(),
|
||||
tree_in_doc: self.upcast::<Node>().is_in_doc(),
|
||||
};
|
||||
shadow_root.bind_to_tree(&bind_context);
|
||||
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
|
||||
|
@ -3586,13 +3588,7 @@ impl VirtualMethods for Element {
|
|||
let doc = document_from_node(self);
|
||||
|
||||
if let Some(ref shadow_root) = self.shadow_root() {
|
||||
doc.register_shadow_root(shadow_root);
|
||||
let shadow_root = shadow_root.upcast::<Node>();
|
||||
shadow_root.set_flag(NodeFlags::IS_CONNECTED, context.tree_connected);
|
||||
for node in shadow_root.children() {
|
||||
node.set_flag(NodeFlags::IS_CONNECTED, context.tree_connected);
|
||||
node.bind_to_tree(context);
|
||||
}
|
||||
shadow_root.bind_to_tree(context);
|
||||
}
|
||||
|
||||
if !context.tree_connected {
|
||||
|
@ -3637,13 +3633,7 @@ impl VirtualMethods for Element {
|
|||
let doc = document_from_node(self);
|
||||
|
||||
if let Some(ref shadow_root) = self.shadow_root() {
|
||||
doc.unregister_shadow_root(shadow_root);
|
||||
let shadow_root = shadow_root.upcast::<Node>();
|
||||
shadow_root.set_flag(NodeFlags::IS_CONNECTED, false);
|
||||
for node in shadow_root.children() {
|
||||
node.set_flag(NodeFlags::IS_CONNECTED, false);
|
||||
node.unbind_from_tree(context);
|
||||
}
|
||||
shadow_root.unbind_from_tree(context);
|
||||
}
|
||||
|
||||
let fullscreen = doc.GetFullscreenElement();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue