mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-20 22:27:31 +09:00
Bug 1406325 - Part 2: Set CustomElementData when cloning a node.
Tag UXP Issue #1344
This commit is contained in:
parent
cce9b3379a
commit
05b01709b8
2 changed files with 70 additions and 4 deletions
|
|
@ -486,12 +486,12 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
||||||
CustomElementDefinition* definition = nullptr;
|
CustomElementDefinition* definition = nullptr;
|
||||||
RefPtr<nsIAtom> tagAtom = nodeInfo->NameAtom();
|
RefPtr<nsIAtom> tagAtom = nodeInfo->NameAtom();
|
||||||
if (nsContentUtils::IsCustomElementName(tagAtom)) {
|
if (nsContentUtils::IsCustomElementName(tagAtom)) {
|
||||||
|
elem->SetCustomElementData(new CustomElementData(tagAtom));
|
||||||
definition =
|
definition =
|
||||||
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
|
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
|
||||||
nodeInfo->LocalName(),
|
nodeInfo->LocalName(),
|
||||||
nodeInfo->NamespaceID());
|
nodeInfo->NamespaceID());
|
||||||
if (definition) {
|
if (definition) {
|
||||||
elem->SetCustomElementData(new CustomElementData(tagAtom));
|
|
||||||
nsContentUtils::EnqueueUpgradeReaction(elem, definition);
|
nsContentUtils::EnqueueUpgradeReaction(elem, definition);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -500,14 +500,14 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
||||||
nsAutoString extension;
|
nsAutoString extension;
|
||||||
if (elem->GetAttr(kNameSpaceID_None, nsGkAtoms::is, extension) &&
|
if (elem->GetAttr(kNameSpaceID_None, nsGkAtoms::is, extension) &&
|
||||||
!extension.IsEmpty()) {
|
!extension.IsEmpty()) {
|
||||||
|
RefPtr<nsAtom> typeAtom = NS_Atomize(extension);
|
||||||
|
elem->SetCustomElementData(new CustomElementData(typeAtom));
|
||||||
definition =
|
definition =
|
||||||
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
|
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
|
||||||
nodeInfo->LocalName(),
|
nodeInfo->LocalName(),
|
||||||
nodeInfo->NamespaceID(),
|
nodeInfo->NamespaceID(),
|
||||||
&extension);
|
&extension);
|
||||||
if (definition) {
|
if (definition) {
|
||||||
RefPtr<nsIAtom> typeAtom = NS_Atomize(extension);
|
|
||||||
elem->SetCustomElementData(new CustomElementData(typeAtom));
|
|
||||||
nsContentUtils::EnqueueUpgradeReaction(elem, definition);
|
nsContentUtils::EnqueueUpgradeReaction(elem, definition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -549,7 +549,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
||||||
// shadow-including inclusive descendants that is custom.
|
// shadow-including inclusive descendants that is custom.
|
||||||
Element* element = aNode->IsElement() ? aNode->AsElement() : nullptr;
|
Element* element = aNode->IsElement() ? aNode->AsElement() : nullptr;
|
||||||
if (element) {
|
if (element) {
|
||||||
RefPtr<CustomElementData> data = element->GetCustomElementData();
|
CustomElementData* data = element->GetCustomElementData();
|
||||||
if (data && data->mState == CustomElementData::State::eCustom) {
|
if (data && data->mState == CustomElementData::State::eCustom) {
|
||||||
LifecycleAdoptedCallbackArgs args = {
|
LifecycleAdoptedCallbackArgs args = {
|
||||||
oldDoc,
|
oldDoc,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1378079
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test throw on dynamic markup insertion when creating element synchronously from parser</title>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1378079">Bug 1378079</a>
|
||||||
|
<div id="container"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
class DoDocumentOpenInCtor extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
document.open();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
customElements.define('x-document-open-in-ctor', DoDocumentOpenInCtor);
|
||||||
|
|
||||||
|
class DoDocumentWriteInCtor extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
document.write('<div>This should not be shown</div>');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
customElements.define('x-document-write-in-ctor', DoDocumentWriteInCtor);
|
||||||
|
|
||||||
|
class DoDocumentCloseInCtor extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
document.close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
customElements.define('x-document-close-in-ctor', DoDocumentCloseInCtor);
|
||||||
|
|
||||||
|
window.errors = [];
|
||||||
|
window.onerror = function(message, url, lineNumber, columnNumber, error) {
|
||||||
|
errors.push(error.name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
var expectedErrorCount = 0;
|
||||||
|
|
||||||
|
document.write("<x-document-open-in-ctor></x-document-open-in-ctor>");
|
||||||
|
expectedErrorCount++;
|
||||||
|
is(window.errors.length, expectedErrorCount, "expectedErrorCount should be " + expectedErrorCount);
|
||||||
|
is(window.errors[expectedErrorCount - 1], 'InvalidStateError', "Error name should be 'InvalidStateError'");
|
||||||
|
|
||||||
|
document.write("<x-document-write-in-ctor></x-document-write-in-ctor>");
|
||||||
|
expectedErrorCount++;
|
||||||
|
is(window.errors.length, expectedErrorCount, "expectedErrorCount should be " + expectedErrorCount);
|
||||||
|
is(window.errors[expectedErrorCount - 1], 'InvalidStateError', "Error name should be 'InvalidStateError'");
|
||||||
|
|
||||||
|
document.write("<x-document-close-in-ctor></x-document-close-in-ctor>");
|
||||||
|
expectedErrorCount++;
|
||||||
|
is(window.errors.length, expectedErrorCount, "expectedErrorCount should be " + expectedErrorCount);
|
||||||
|
is(window.errors[expectedErrorCount - 1], 'InvalidStateError', "Error name should be 'InvalidStateError'");
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue