mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
Bug 1406325 - Part 3: Refactor custom elements clone a node.
Tag UXP Issue #1344
This commit is contained in:
parent
05b01709b8
commit
c4718c47bb
1 changed files with 19 additions and 25 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue