summaryrefslogtreecommitdiffstats
path: root/dom/base/Element.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/Element.cpp')
-rw-r--r--dom/base/Element.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp
index fdaaed62a..e77b43b86 100644
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1688,8 +1688,13 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// Connected callback must be enqueued whenever a custom element becomes
// connected.
CustomElementData* data = GetCustomElementData();
- if (data && data->mState == CustomElementData::State::eCustom) {
- nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eConnected, this);
+ if (data) {
+ if (data->mState == CustomElementData::State::eCustom) {
+ nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eConnected, this);
+ } else {
+ // Step 7.7.2.2 https://dom.spec.whatwg.org/#concept-node-insert
+ nsContentUtils::TryToUpgradeElement(this);
+ }
}
}
@@ -1988,9 +1993,16 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
// disconnected.
if (CustomElementRegistry::IsCustomElementEnabled()) {
CustomElementData* data = GetCustomElementData();
- if (data && data->mState == CustomElementData::State::eCustom) {
- nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eDisconnected,
- this);
+ if (data) {
+ if (data->mState == CustomElementData::State::eCustom) {
+ nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eDisconnected,
+ this);
+ } else {
+ // Remove an unresolved custom element that is a candidate for
+ // upgrade when a custom element is disconnected.
+ // We will make sure it's shadow-including tree order in bug 1326028.
+ nsContentUtils::UnregisterUnresolvedElement(this);
+ }
}
}
}