diff options
Diffstat (limited to 'dom/base/Element.cpp')
-rw-r--r-- | dom/base/Element.cpp | 75 |
1 files changed, 44 insertions, 31 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 247fbe79e..5719b423d 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -2586,23 +2586,29 @@ Element::SetAttrAndNotify(int32_t aNamespaceID, UpdateState(aNotify); - nsIDocument* ownerDoc = OwnerDoc(); - if (ownerDoc && GetCustomElementData()) { - nsCOMPtr<nsIAtom> oldValueAtom = oldValue->GetAsAtom(); - nsCOMPtr<nsIAtom> newValueAtom = valueForAfterSetAttr.GetAsAtom(); - nsAutoString ns; - nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns); - - LifecycleCallbackArgs args = { - nsDependentAtomString(aName), - aModType == nsIDOMMutationEvent::ADDITION ? - NullString() : nsDependentAtomString(oldValueAtom), - nsDependentAtomString(newValueAtom), - (ns.IsEmpty() ? NullString() : ns) - }; - - nsContentUtils::EnqueueLifecycleCallback( - ownerDoc, nsIDocument::eAttributeChanged, this, &args); + if (nsContentUtils::IsWebComponentsEnabled()) { + if (CustomElementData* data = GetCustomElementData()) { + if (CustomElementDefinition* definition = + nsContentUtils::GetElementDefinitionIfObservingAttr(this, + data->mType, + aName)) { + nsCOMPtr<nsIAtom> oldValueAtom = oldValue->GetAsAtom(); + nsCOMPtr<nsIAtom> newValueAtom = valueForAfterSetAttr.GetAsAtom(); + nsAutoString ns; + nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns); + + LifecycleCallbackArgs args = { + nsDependentAtomString(aName), + aModType == nsIDOMMutationEvent::ADDITION ? + NullString() : nsDependentAtomString(oldValueAtom), + nsDependentAtomString(newValueAtom), + (ns.IsEmpty() ? NullString() : ns) + }; + + nsContentUtils::EnqueueLifecycleCallback( + OwnerDoc(), nsIDocument::eAttributeChanged, this, &args, definition); + } + } } if (aCallAfterSetAttr) { @@ -2847,20 +2853,27 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, UpdateState(aNotify); - nsIDocument* ownerDoc = OwnerDoc(); - if (ownerDoc && GetCustomElementData()) { - nsAutoString ns; - nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns); - nsCOMPtr<nsIAtom> oldValueAtom = oldValue.GetAsAtom(); - LifecycleCallbackArgs args = { - nsDependentAtomString(aName), - nsDependentAtomString(oldValueAtom), - NullString(), - (ns.IsEmpty() ? NullString() : ns) - }; - - nsContentUtils::EnqueueLifecycleCallback( - ownerDoc, nsIDocument::eAttributeChanged, this, &args); + if (nsContentUtils::IsWebComponentsEnabled()) { + if (CustomElementData* data = GetCustomElementData()) { + if (CustomElementDefinition* definition = + nsContentUtils::GetElementDefinitionIfObservingAttr(this, + data->mType, + aName)) { + nsAutoString ns; + nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns); + + nsCOMPtr<nsIAtom> oldValueAtom = oldValue.GetAsAtom(); + LifecycleCallbackArgs args = { + nsDependentAtomString(aName), + nsDependentAtomString(oldValueAtom), + NullString(), + (ns.IsEmpty() ? NullString() : ns) + }; + + nsContentUtils::EnqueueLifecycleCallback( + OwnerDoc(), nsIDocument::eAttributeChanged, this, &args, definition); + } + } } if (aNotify) { |