summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
Diffstat (limited to 'dom')
-rw-r--r--dom/base/nsNodeUtils.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp
index 3670b5438..85cd791c5 100644
--- a/dom/base/nsNodeUtils.cpp
+++ b/dom/base/nsNodeUtils.cpp
@@ -479,37 +479,31 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
rv = aNode->Clone(nodeInfo, getter_AddRefs(clone));
NS_ENSURE_SUCCESS(rv, rv);
- if (CustomElementRegistry::IsCustomElementEnabled() && clone->IsElement()) {
+ if (CustomElementRegistry::IsCustomElementEnabled() &&
+ clone->IsHTMLElement()) {
// The cloned node may be a custom element that may require
// enqueing upgrade reaction.
- Element* elem = clone->AsElement();
- CustomElementDefinition* definition = nullptr;
+ Element* cloneElem = clone->AsElement();
RefPtr<nsIAtom> tagAtom = nodeInfo->NameAtom();
- if (nsContentUtils::IsCustomElementName(tagAtom)) {
- elem->SetCustomElementData(new CustomElementData(tagAtom));
- definition =
+ CustomElementData* data = elem->GetCustomElementData();
+
+ // Check if node may be custom element by type extension.
+ // ex. <button is="x-button">
+ nsAutoString extension;
+ if (!data || data->GetCustomElementType() != tagAtom) {
+ cloneElem->GetAttr(kNameSpaceID_None, nsGkAtoms::is, extension);
+ }
+
+ if (data || !extension.IsEmpty()) {
+ RefPtr<nsIAtom> typeAtom = extension.IsEmpty() ? tagAtom : NS_Atomize(extension);
+ cloneElem->SetCustomElementData(new CustomElementData(typeAtom));
+ CustomElementDefinition* definition =
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
nodeInfo->LocalName(),
- nodeInfo->NamespaceID());
+ nodeInfo->NamespaceID(),
+ extension.IsEmpty() ? nullptr : &extension);
if (definition) {
- 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()) {
- RefPtr<nsAtom> typeAtom = NS_Atomize(extension);
- elem->SetCustomElementData(new CustomElementData(typeAtom));
- definition =
- nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
- nodeInfo->LocalName(),
- nodeInfo->NamespaceID(),
- &extension);
- if (definition) {
- nsContentUtils::EnqueueUpgradeReaction(elem, definition);
- }
+ nsContentUtils::EnqueueUpgradeReaction(cloneElem, definition);
}
}
}