samedi 21 mars 2015

Why does adding 2 inputs cause five mutation events

How come I get 5 mutation events for adding this to a page? (actuall ember adds it when it changes route, but its within the ember div)



<input type="text" placeholder="login">
<input type="password" placeholder="password">


x5



MutationRecord {oldValue: null, attributeNamespace: null, attributeName: null, nextSibling: text, previousSibling: text…}


Only the last one is of interest: it has a NodeList[4] , but the others have one of NodeList[0] my code:



var MutationObserver = window.MutationObserver;

var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {

console.log(mutation);
});
});
var config = {attributes: true, childList: true, characterData: true};
observer.observe(emberTarget, config);




Aucun commentaire:

Enregistrer un commentaire