diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index ce023ccfad..862b5db14b 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 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.