Skip to content
Permalink
Browse files

Set self as containing_shadow_root for shadow roots

  • Loading branch information...
ferjm committed Apr 29, 2019
1 parent 68bee1c commit 37e88e77cdf00e3555599dd4004d03548bd95dcf
Showing with 3 additions and 8 deletions.
  1. +3 −0 components/script/dom/element.rs
  2. +0 −8 components/script/dom/node.rs
@@ -497,6 +497,9 @@ impl Element {
// Steps 4, 5 and 6.
let shadow_root = ShadowRoot::new(self, &*self.node.owner_doc());
self.ensure_rare_data().shadow_root = Some(Dom::from_ref(&*shadow_root));
shadow_root
.upcast::<Node>()
.set_containing_shadow_root(&shadow_root);

if self.is_connected() {
self.node.owner_doc().register_shadow_root(&*shadow_root);
@@ -947,11 +947,6 @@ impl Node {
}

pub fn containing_shadow_root(&self) -> Option<DomRoot<ShadowRoot>> {
// NodeRareData contains the shadow root the node belongs to,
// but this node may be a shadow root itself.
if let Some(ref shadow_root) = self.downcast::<ShadowRoot>() {
return Some(DomRoot::from_ref(shadow_root));
}
self.rare_data()
.as_ref()?
.containing_shadow_root
@@ -1281,9 +1276,6 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
#[inline]
#[allow(unsafe_code)]
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>> {
if let Some(ref shadow_root) = self.downcast::<ShadowRoot>() {
return Some(*shadow_root);
}
(*self.unsafe_get())
.rare_data_for_layout()
.as_ref()?

0 comments on commit 37e88e7

Please sign in to comment.
You can’t perform that action at this time.