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
This commit is contained in:
Gaming4JC 2020-01-05 11:25:37 -05:00 committed by Roy Tam
commit 4408e19e96
4 changed files with 15 additions and 4 deletions

View file

@ -52,7 +52,7 @@ CustomElementCallback::Call()
break;
case nsIDocument::eAttributeChanged:
static_cast<LifecycleAttributeChangedCallback *>(mCallback.get())->Call(mThisObject,
mArgs.name, mArgs.oldValue, mArgs.newValue, rv);
mArgs.name, mArgs.oldValue, mArgs.newValue, mArgs.namespaceURI, rv);
break;
}
}

View file

@ -34,6 +34,7 @@ struct LifecycleCallbackArgs
nsString name;
nsString oldValue;
nsString newValue;
nsString namespaceURI;
};
class CustomElementCallback

View file

@ -2590,11 +2590,15 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
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)
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<nsIAtom> oldValueAtom = oldValue.GetAsAtom();
LifecycleCallbackArgs args = {
nsDependentAtomString(aName),
nsDependentAtomString(oldValueAtom),
NullString()
NullString(),
(ns.IsEmpty() ? NullString() : ns)
};
nsContentUtils::EnqueueLifecycleCallback(

View file

@ -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;