I noticed that morphdom was updating my DOM way more than I expected, and narrowed it down to the presence of comments. Here's a simple test I added that fails (pull request with naive fix to follow).
it('should not alter the DOM unnecessarily in the presence of comments', function() {
var el1 = document.createElement('div');
el1.innerHTML = '<!-- comment --><div class="div1">a</div>';
var el2 = el1.cloneNode(true);
var addedNodes = [];
var discardedNodes = [];
morphdom(el1, el2, {
onNodeAdded: function(el) { addedNodes.push(el) },
onNodeDiscarded: function(el) { discardedNodes.push(el) }
});
// This was a no-op update, and should have made no changes
expect(addedNodes).to.be.empty;
expect(discardedNodes).to.be.empty;
});
I noticed that morphdom was updating my DOM way more than I expected, and narrowed it down to the presence of comments. Here's a simple test I added that fails (pull request with naive fix to follow).