mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 16:28:38 +09:00
Refactor MaybeCheckSameAttrVal to streamline old value storage for custom elements
This commit is contained in:
parent
81e2ff2fe2
commit
d34a9c5778
1 changed files with 10 additions and 11 deletions
|
|
@ -2336,6 +2336,7 @@ Element::MaybeCheckSameAttrVal(int32_t aNamespaceID,
|
|||
bool* aOldValueSet)
|
||||
{
|
||||
bool modification = false;
|
||||
CustomElementData* customElementData = GetCustomElementData();
|
||||
*aHasListeners = aNotify &&
|
||||
nsContentUtils::HasMutationListeners(this,
|
||||
NS_EVENT_BITS_MUTATION_ATTRMODIFIED,
|
||||
|
|
@ -2351,13 +2352,14 @@ Element::MaybeCheckSameAttrVal(int32_t aNamespaceID,
|
|||
if (*aHasListeners || aNotify) {
|
||||
BorrowedAttrInfo info(GetAttrInfo(aNamespaceID, aName));
|
||||
if (info.mValue) {
|
||||
// Check whether the old value is the same as the new one. Note that we
|
||||
// only need to actually _get_ the old value if we have listeners or
|
||||
// if the element is a custom element (because it may have an
|
||||
// attribute changed callback).
|
||||
if (*aHasListeners || GetCustomElementData()) {
|
||||
// Need to store the old value.
|
||||
//
|
||||
bool valueMatches = aValue.EqualsAsStrings(*info.mValue);
|
||||
if (valueMatches && aPrefix == info.mName->GetPrefix()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Need to store the old value if listeners are present or this is a
|
||||
// custom element that may run an attribute-changed callback.
|
||||
if (*aHasListeners || customElementData) {
|
||||
// If the current attribute value contains a pointer to some other data
|
||||
// structure that gets updated in the process of setting the attribute
|
||||
// we'll no longer have the old value of the attribute. Therefore, we
|
||||
|
|
@ -2368,10 +2370,7 @@ Element::MaybeCheckSameAttrVal(int32_t aNamespaceID,
|
|||
aOldValue.SetToSerialized(*info.mValue);
|
||||
*aOldValueSet = true;
|
||||
}
|
||||
bool valueMatches = aValue.EqualsAsStrings(*info.mValue);
|
||||
if (valueMatches && aPrefix == info.mName->GetPrefix()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
modification = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue