From 4408e19e962c362bb57bc7ce66d4c10927bcbf0c Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sun, 5 Jan 2020 11:25:37 -0500 Subject: [PATCH] Bug 1334051 - Part 1: Include namespace in attributeChangedCallback. Per spec [1], we should include namesapce in attributeChangedCallback argurment list. [1] https://html.spec.whatwg.org/multipage/custom-elements.html#concept-upgrade-an-element, step 3 Tag UXP Issue #1344 --- dom/base/CustomElementRegistry.cpp | 2 +- dom/base/CustomElementRegistry.h | 1 + dom/base/Element.cpp | 11 +++++++++-- dom/webidl/WebComponents.webidl | 5 ++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index e619ad599f..cc6264b038 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -52,7 +52,7 @@ CustomElementCallback::Call() break; case nsIDocument::eAttributeChanged: static_cast(mCallback.get())->Call(mThisObject, - mArgs.name, mArgs.oldValue, mArgs.newValue, rv); + mArgs.name, mArgs.oldValue, mArgs.newValue, mArgs.namespaceURI, rv); break; } } diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index c45f3f70c4..b5903f9789 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -34,6 +34,7 @@ struct LifecycleCallbackArgs nsString name; nsString oldValue; nsString newValue; + nsString namespaceURI; }; class CustomElementCallback diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 81cc412103..247fbe79eb 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -2590,11 +2590,15 @@ Element::SetAttrAndNotify(int32_t aNamespaceID, if (ownerDoc && GetCustomElementData()) { nsCOMPtr oldValueAtom = oldValue->GetAsAtom(); nsCOMPtr newValueAtom = valueForAfterSetAttr.GetAsAtom(); + nsAutoString ns; + nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns); + LifecycleCallbackArgs args = { nsDependentAtomString(aName), aModType == nsIDOMMutationEvent::ADDITION ? NullString() : nsDependentAtomString(oldValueAtom), - nsDependentAtomString(newValueAtom) + nsDependentAtomString(newValueAtom), + (ns.IsEmpty() ? NullString() : ns) }; nsContentUtils::EnqueueLifecycleCallback( @@ -2845,11 +2849,14 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIDocument* ownerDoc = OwnerDoc(); if (ownerDoc && GetCustomElementData()) { + nsAutoString ns; + nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns); nsCOMPtr oldValueAtom = oldValue.GetAsAtom(); LifecycleCallbackArgs args = { nsDependentAtomString(aName), nsDependentAtomString(oldValueAtom), - NullString() + NullString(), + (ns.IsEmpty() ? NullString() : ns) }; nsContentUtils::EnqueueLifecycleCallback( diff --git a/dom/webidl/WebComponents.webidl b/dom/webidl/WebComponents.webidl index 3dfb960bc1..19ca38c0d9 100644 --- a/dom/webidl/WebComponents.webidl +++ b/dom/webidl/WebComponents.webidl @@ -13,7 +13,10 @@ callback LifecycleCreatedCallback = void(); callback LifecycleAttachedCallback = void(); callback LifecycleDetachedCallback = void(); -callback LifecycleAttributeChangedCallback = void(DOMString attrName, DOMString? oldValue, DOMString? newValue); +callback LifecycleAttributeChangedCallback = void(DOMString attrName, + DOMString? oldValue, + DOMString? newValue, + DOMString? namespaceURI); dictionary LifecycleCallbacks { LifecycleCreatedCallback? createdCallback;