From 5f12940329ba496da5730863cae94cd8c0b145da Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 06:34:38 -0400 Subject: Bug 1396584 - Remove support for multiple ShadowRoots Tag #1375 --- dom/base/Element.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'dom/base/Element.cpp') diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index a2b78092a..5bbfbee9b 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1095,6 +1095,11 @@ Element::RemoveFromIdTable() already_AddRefed Element::CreateShadowRoot(ErrorResult& aError) { + if (GetShadowRoot()) { + aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return nullptr; + } + nsAutoScriptBlocker scriptBlocker; RefPtr nodeInfo; @@ -1131,24 +1136,7 @@ Element::CreateShadowRoot(ErrorResult& aError) shadowRoot->SetIsComposedDocParticipant(IsInComposedDoc()); - // Replace the old ShadowRoot with the new one and let the old - // ShadowRoot know about the younger ShadowRoot because the old - // ShadowRoot is projected into the younger ShadowRoot's shadow - // insertion point (if it exists). - ShadowRoot* olderShadow = GetShadowRoot(); SetShadowRoot(shadowRoot); - if (olderShadow) { - olderShadow->SetYoungerShadow(shadowRoot); - - // Unbind children of older shadow root because they - // are no longer in the composed tree. - for (nsIContent* child = olderShadow->GetFirstChild(); child; - child = child->GetNextSibling()) { - child->UnbindFromTree(true, false); - } - - olderShadow->SetIsComposedDocParticipant(false); - } // xblBinding takes ownership of docInfo. RefPtr xblBinding = new nsXBLBinding(shadowRoot, protoBinding); -- cgit v1.2.3