mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-15 06:20:41 +00:00
Bug 1444909 part 1. Fix DOMTokenList.replace() to not do the attr set when the old token was not found. r=qdot
This fixes upcoming tests that will check when we actually mutate the attribute. MozReview-Commit-ID: 7r5ErK9wvir
This commit is contained in:
parent
8a5136ff57
commit
cbabf9ebea
@ -352,6 +352,20 @@ nsDOMTokenList::ReplaceInternal(const nsAttrValue* aAttr,
|
||||
{
|
||||
RemoveDuplicates(aAttr);
|
||||
|
||||
// Trying to do a single pass here leads to really complicated code. Just do
|
||||
// the simple thing.
|
||||
bool haveOld = false;
|
||||
for (uint32_t i = 0; i < aAttr->GetAtomCount(); ++i) {
|
||||
if (aAttr->AtomAt(i)->Equals(aToken)) {
|
||||
haveOld = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!haveOld) {
|
||||
// Make sure to not touch the attribute value in this case.
|
||||
return;
|
||||
}
|
||||
|
||||
bool sawIt = false;
|
||||
nsAutoString resultStr;
|
||||
for (uint32_t i = 0; i < aAttr->GetAtomCount(); i++) {
|
||||
@ -374,9 +388,8 @@ nsDOMTokenList::ReplaceInternal(const nsAttrValue* aAttr,
|
||||
resultStr.Append(nsDependentAtomString(aAttr->AtomAt(i)));
|
||||
}
|
||||
|
||||
if (sawIt) {
|
||||
mElement->SetAttr(kNameSpaceID_None, mAttrAtom, resultStr, true);
|
||||
}
|
||||
MOZ_ASSERT(sawIt, "How could we not have found our token this time?");
|
||||
mElement->SetAttr(kNameSpaceID_None, mAttrAtom, resultStr, true);
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user