mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-24 08:07:30 +09:00
Issue #1375 - Implement customElements.upgrade.
Backported from Mozilla bug 1443722.
This commit is contained in:
parent
3ea1f776a9
commit
bc36c607a9
3 changed files with 42 additions and 0 deletions
|
|
@ -791,6 +791,45 @@ CustomElementRegistry::Define(const nsAString& aName,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
TryUpgrade(nsINode& aNode)
|
||||||
|
{
|
||||||
|
Element* element = aNode.IsElement() ? aNode.AsElement() : nullptr;
|
||||||
|
if (element) {
|
||||||
|
CustomElementData* ceData = element->GetCustomElementData();
|
||||||
|
if (ceData) {
|
||||||
|
NodeInfo* nodeInfo = element->NodeInfo();
|
||||||
|
nsAtom* typeAtom = ceData->GetCustomElementType();
|
||||||
|
CustomElementDefinition* definition =
|
||||||
|
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
|
||||||
|
nodeInfo->NameAtom(),
|
||||||
|
nodeInfo->NamespaceID(),
|
||||||
|
typeAtom);
|
||||||
|
if (definition) {
|
||||||
|
nsContentUtils::EnqueueUpgradeReaction(element, definition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ShadowRoot* root = element->GetShadowRoot()) {
|
||||||
|
for (Element* child = root->GetFirstElementChild(); child;
|
||||||
|
child = child->GetNextElementSibling()) {
|
||||||
|
TryUpgrade(*child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Element* child = aNode.GetFirstElementChild(); child;
|
||||||
|
child = child->GetNextElementSibling()) {
|
||||||
|
TryUpgrade(*child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CustomElementRegistry::Upgrade(nsINode& aRoot)
|
||||||
|
{
|
||||||
|
TryUpgrade(aRoot);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CustomElementRegistry::Get(JSContext* aCx, const nsAString& aName,
|
CustomElementRegistry::Get(JSContext* aCx, const nsAString& aName,
|
||||||
JS::MutableHandle<JS::Value> aRetVal)
|
JS::MutableHandle<JS::Value> aRetVal)
|
||||||
|
|
|
||||||
|
|
@ -525,6 +525,8 @@ public:
|
||||||
JS::MutableHandle<JS::Value> aRetVal);
|
JS::MutableHandle<JS::Value> aRetVal);
|
||||||
|
|
||||||
already_AddRefed<Promise> WhenDefined(const nsAString& aName, ErrorResult& aRv);
|
already_AddRefed<Promise> WhenDefined(const nsAString& aName, ErrorResult& aRv);
|
||||||
|
|
||||||
|
void Upgrade(nsINode& aRoot);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MOZ_RAII AutoCEReaction final {
|
class MOZ_RAII AutoCEReaction final {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ interface CustomElementRegistry {
|
||||||
any get(DOMString name);
|
any get(DOMString name);
|
||||||
[Throws]
|
[Throws]
|
||||||
Promise<void> whenDefined(DOMString name);
|
Promise<void> whenDefined(DOMString name);
|
||||||
|
[CEReactions] void upgrade(Node root);
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary ElementDefinitionOptions {
|
dictionary ElementDefinitionOptions {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue