diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2020-01-19 22:17:12 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2020-01-26 15:50:45 -0500 |
commit | e62385604d8003b223a35dd79ceefa483d15aab6 (patch) | |
tree | d80714d3066ea625b8cc599f0f43a37f5d41a571 /dom | |
parent | a0014ac6e9e751f9f9bf68c1a345394bbcfd096f (diff) | |
download | UXP-e62385604d8003b223a35dd79ceefa483d15aab6.tar UXP-e62385604d8003b223a35dd79ceefa483d15aab6.tar.gz UXP-e62385604d8003b223a35dd79ceefa483d15aab6.tar.lz UXP-e62385604d8003b223a35dd79ceefa483d15aab6.tar.xz UXP-e62385604d8003b223a35dd79ceefa483d15aab6.zip |
Bug 1406325 - Part 1: Make sure custom element state is custom before sending callback.
Tag UXP Issue #1344
Diffstat (limited to 'dom')
-rw-r--r-- | dom/base/Element.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 9efa01439..9f9c8e6c0 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1687,7 +1687,8 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent, if (CustomElementRegistry::IsCustomElementEnabled() && IsInComposedDoc()) { // Connected callback must be enqueued whenever a custom element becomes // connected. - if (GetCustomElementData()) { + CustomElementData* data = GetCustomElementData(); + if (data && data->mState == CustomElementData::State::eCustom) { nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eConnected, this); } } @@ -1985,10 +1986,12 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent) // Disconnected must be enqueued whenever a connected custom element becomes // disconnected. - if (CustomElementRegistry::IsCustomElementEnabled() && - GetCustomElementData()) { - nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eDisconnected, - this); + if (CustomElementRegistry::IsCustomElementEnabled()) { + CustomElementData* data = GetCustomElementData(); + if (data && data->mState == CustomElementData::State::eCustom) { + nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eDisconnected, + this); + } } } @@ -2589,6 +2592,9 @@ Element::SetAttrAndNotify(int32_t aNamespaceID, nsContentUtils::GetElementDefinitionIfObservingAttr(this, data->mType, aName)) { + MOZ_ASSERT(data->mState == CustomElementData::State::eCustom, + "AttributeChanged callback should fire only if " + "custom element state is custom"); nsCOMPtr<nsIAtom> oldValueAtom = oldValue->GetAsAtom(); nsCOMPtr<nsIAtom> newValueAtom = valueForAfterSetAttr.GetAsAtom(); nsAutoString ns; @@ -2856,6 +2862,9 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsContentUtils::GetElementDefinitionIfObservingAttr(this, data->mType, aName)) { + MOZ_ASSERT(data->mState == CustomElementData::State::eCustom, + "AttributeChanged callback should fire only if " + "custom element state is custom"); nsAutoString ns; nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns); |