Bug 1879001 - Remove the popovertarget attribute or set it to an invalid value should clear the explicitly set attr-element. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D201711
This commit is contained in:
Ziran Sun
2024-02-16 21:51:24 +00:00
parent 3a411e96d5
commit 021e5f2541
5 changed files with 46 additions and 9 deletions

View File

@@ -1767,19 +1767,23 @@ Element* Element::GetAttrAssociatedElement(nsAtom* aAttr) const {
return nullptr;
}
void Element::ClearExplicitlySetAttrElement(nsAtom* aAttr) {
if (auto* slots = GetExistingExtendedDOMSlots()) {
slots->mExplicitlySetAttrElements.Remove(aAttr);
}
}
void Element::ExplicitlySetAttrElement(nsAtom* aAttr, Element* aElement) {
if (aElement) {
SetAttr(aAttr, EmptyString(), IgnoreErrors());
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
slots->mExplicitlySetAttrElements.InsertOrUpdate(
aAttr, do_GetWeakReference(aElement));
SetAttr(aAttr, EmptyString(), IgnoreErrors());
return;
}
if (auto* slots = GetExistingExtendedDOMSlots()) {
slots->mExplicitlySetAttrElements.Remove(aAttr);
UnsetAttr(aAttr, IgnoreErrors());
}
ClearExplicitlySetAttrElement(aAttr);
UnsetAttr(aAttr, IgnoreErrors());
}
void Element::GetElementsWithGrid(nsTArray<RefPtr<Element>>& aElements) {