mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
Bug 1319342 - Clone a node should enqueue an upgrade reaction.
Tag UXP Issue #1344
This commit is contained in:
parent
d35ff2985e
commit
f077bd93a4
6 changed files with 23 additions and 97 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue