Bug 1419310 - Part 2: Enqueue an attributeChanged reaction when mutating the value of an observed attribute to the same value; r=smaug

MozReview-Commit-ID: GyRL6Xt8HWt

--HG--
extra : rebase_source : 657cdf6dcad0f886f99a2e466a19cfb45c9195dc
This commit is contained in:
Edgar Chen 2017-11-22 23:48:34 +08:00
Родитель b3ea0a20d4
Коммит f6cde405ab
4 изменённых файлов: 30 добавлений и 20 удалений

Просмотреть файл

@ -2986,6 +2986,35 @@ Element::PostIdMaybeChange(int32_t aNamespaceID, nsAtom* aName,
}
}
nsresult
Element::OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValueOrString& aValue,
bool aNotify)
{
if (CustomElementRegistry::IsCustomElementEnabled()) {
// Only custom element which is in `custom` state could get the
// CustomElementDefinition.
CustomElementDefinition* definition = GetCustomElementDefinition();
if (definition && definition->IsInObservedAttributeList(aName)) {
nsAutoString ns;
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns);
nsAutoString value(aValue.String());
LifecycleCallbackArgs args = {
nsDependentAtomString(aName),
value,
value,
(ns.IsEmpty() ? VoidString() : ns)
};
nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eAttributeChanged,
this, &args, nullptr, definition);
}
}
return NS_OK;
}
EventListenerManager*
Element::GetEventListenerManagerForAttr(nsAtom* aAttrName,
bool* aDefer)

Просмотреть файл

@ -1710,10 +1710,7 @@ protected:
// inlined. Those calls don't go through a vtable.
virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValueOrString& aValue,
bool aNotify)
{
return NS_OK;
}
bool aNotify);
/**
* Hook to allow subclasses to produce a different EventListenerManager if

Просмотреть файл

@ -1,5 +0,0 @@
[DOMStringMap.html]
type: testharness
[setter on DOMStringMap must enqueue an attributeChanged reaction when mutating the value of an observed data attribute to the same value]
expected: FAIL

Просмотреть файл

@ -1,11 +0,0 @@
[DOMTokenList.html]
type: testharness
[remove on DOMTokenList must not enqueue an attributeChanged reaction when removing a non-existent value from an attribute]
expected: FAIL
[the stringifier of DOMTokenList must enqueue an attributeChanged reaction when the setter is called with the original value of the attribute]
expected: FAIL
[remove on DOMTokenList must enqueue an attributeChanged reaction even when removing a non-existent value from an attribute]
expected: FAIL