зеркало из https://github.com/mozilla/pjs.git
Bug 757700, make sure attr modification type is set, r=sicking
--HG-- extra : rebase_source : ed2b2cc803cbd494b33a4e343efee9bd76f7e54a
This commit is contained in:
Родитель
14a3fb095e
Коммит
0d4aad123b
|
@ -5162,7 +5162,13 @@ nsGenericElement::MaybeCheckSameAttrVal(PRInt32 aNamespaceID,
|
|||
}
|
||||
bool valueMatches = aValue.EqualsAsStrings(*info.mValue);
|
||||
if (valueMatches && aPrefix == info.mName->GetPrefix()) {
|
||||
return !OwnerDoc()->MayHaveDOMMutationObservers();
|
||||
if (OwnerDoc()->MayHaveDOMMutationObservers()) {
|
||||
// For backward compatibility, don't fire mutation events
|
||||
// when setting an attribute to its old value.
|
||||
*aHasListeners = false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
modification = true;
|
||||
}
|
||||
|
|
|
@ -509,7 +509,7 @@ function testTakeRecords() {
|
|||
|
||||
is(m.takeRecords().length, 0, "Shouldn't have any records");
|
||||
observer.disconnect();
|
||||
then();
|
||||
then(testMutationObserverAndEvents);
|
||||
m = null;
|
||||
});
|
||||
m.observe(div, { childList: true, attributes: true });
|
||||
|
@ -522,6 +522,31 @@ function testTakeRecords() {
|
|||
div.removeAttribute("foo");
|
||||
}
|
||||
|
||||
function testTakeRecords() {
|
||||
m = new M(function(records, observer) {
|
||||
is(records.length, 2, "Should have got 2 records");
|
||||
is(records[0].type, "attributes", "Should have got attributes");
|
||||
is(records[0].attributeName, "foo", "");
|
||||
is(records[0].oldValue, null, "");
|
||||
is(records[1].type, "attributes", "Should have got attributes");
|
||||
is(records[1].attributeName, "foo", "");
|
||||
is(records[1].oldValue, "bar", "");
|
||||
observer.disconnect();
|
||||
then();
|
||||
m = null;
|
||||
});
|
||||
m.observe(div, { attributes: true, attributeOldValue: true });
|
||||
var mutationEventCount = 0;
|
||||
div.addEventListener("DOMAttrModified",
|
||||
function(e) {
|
||||
++mutationEventCount;
|
||||
is(e.attrChange, MutationEvent.ADDITION, "unexpected change");
|
||||
});
|
||||
div.setAttribute("foo", "bar");
|
||||
div.setAttribute("foo", "bar");
|
||||
is(mutationEventCount, 1, "Should have got only one mutation event!");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче