Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.



Programming and Learning from SD

We were just in a code review and one of the guys showed how he was using the MutationObserverer with our search control to get tiles to resize after the list (Knockout observable). I hadn’t heard of this before and it looks very useful. Read the linked html5rocks.com page (from 2012) to learn more about it.

It’s supported on all but Opera mini and started in IE 11 and is a more performant than the old Mutation Events that have been deprecated. You point the MutationObserver to the DOM node and it will give you a list of elements in that node that are effected.

var insertedNodes = [];
var observer = new MutationObserver(function(mutations) {
 mutations.forEach(function(mutation) {
   for (var i = 0; i < mutation.addedNodes.length; i++)
     insertedNodes.push(mutation.addedNodes[i]);
 })
});
observer.observe(document, { childList: true });
console.log(insertedNodes);
[Code from the Html5rocks.com article] Posted on Thursday, January 29, 2015 7:55 PM JavaScript | Back to top


Comments on this post: MutationObserver in HTML5

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Aligned | Powered by: GeeksWithBlogs.net