diff options
Diffstat (limited to 'dom/base/nsNodeUtils.cpp')
-rw-r--r-- | dom/base/nsNodeUtils.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index ce023ccfa..862b5db14 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -479,19 +479,37 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, rv = aNode->Clone(nodeInfo, getter_AddRefs(clone)); NS_ENSURE_SUCCESS(rv, rv); - if (clone->IsElement()) { + if (CustomElementRegistry::IsCustomElementEnabled() && clone->IsElement()) { // The cloned node may be a custom element that may require - // enqueing created callback and prototype swizzling. + // enqueing upgrade reaction. Element* elem = clone->AsElement(); - if (nsContentUtils::IsCustomElementName(nodeInfo->NameAtom())) { - nsContentUtils::SetupCustomElement(elem); + CustomElementDefinition* definition = nullptr; + RefPtr<nsIAtom> tagAtom = nodeInfo->NameAtom(); + if (nsContentUtils::IsCustomElementName(tagAtom)) { + definition = + nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(), + nodeInfo->LocalName(), + nodeInfo->NamespaceID()); + if (definition) { + elem->SetCustomElementData(new CustomElementData(tagAtom)); + nsContentUtils::EnqueueUpgradeReaction(elem, definition); + } } else { // Check if node may be custom element by type extension. // ex. <button is="x-button"> nsAutoString extension; if (elem->GetAttr(kNameSpaceID_None, nsGkAtoms::is, extension) && !extension.IsEmpty()) { - nsContentUtils::SetupCustomElement(elem, &extension); + definition = + nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(), + nodeInfo->LocalName(), + nodeInfo->NamespaceID(), + &extension); + if (definition) { + RefPtr<nsIAtom> typeAtom = NS_Atomize(extension); + elem->SetCustomElementData(new CustomElementData(typeAtom)); + nsContentUtils::EnqueueUpgradeReaction(elem, definition); + } } } } |