diff --git a/src/diff/index.js b/src/diff/index.js index e4cf4c033f1..b0bcd188101 100644 --- a/src/diff/index.js +++ b/src/diff/index.js @@ -318,7 +318,13 @@ function diffElementNodes( // // Note: This takes advantage of Text nodes having `.localName=undefined`, // which is loosely equal to Text VNodes' `.type=null`. Elements use string equality. - if (child != null && (dom == child || child.localName == nodeType)) { + if ( + child != null && + ((newVNode.type === null + ? child.nodeType === 3 + : child.localName === newVNode.type) || + dom == child) + ) { dom = child; excessDomChildren[i] = null; break; diff --git a/test/browser/hydrate.test.js b/test/browser/hydrate.test.js index a9ddd92a5f4..5a45e3c3b50 100644 --- a/test/browser/hydrate.test.js +++ b/test/browser/hydrate.test.js @@ -445,4 +445,10 @@ describe('hydrate()', () => { '

hello baz

hello bar

' ); }); + + it('should skip comment nodes', () => { + scratch.innerHTML = '

hello foo

'; + hydrate(

hello {'foo'}

, scratch); + expect(scratch.innerHTML).to.equal('

hello foo

'); + }); });