summaryrefslogtreecommitdiff
path: root/dom/base/Element.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/Element.cpp')
-rw-r--r--dom/base/Element.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp
index a2b78092ad..5bbfbee9b4 100644
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1095,6 +1095,11 @@ Element::RemoveFromIdTable()
already_AddRefed<ShadowRoot>
Element::CreateShadowRoot(ErrorResult& aError)
{
+ if (GetShadowRoot()) {
+ aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+ return nullptr;
+ }
+
nsAutoScriptBlocker scriptBlocker;
RefPtr<mozilla::dom::NodeInfo> 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<nsXBLBinding> xblBinding = new nsXBLBinding(shadowRoot, protoBinding);