diff --git a/src/diff/children.js b/src/diff/children.js index 369014af39..8256e45d74 100644 --- a/src/diff/children.js +++ b/src/diff/children.js @@ -367,7 +367,11 @@ function insert(parentVNode, oldDom, parentDom) { oldDom = parentVNode._dom; } - return oldDom && oldDom.nextSibling; + do { + oldDom = oldDom && oldDom.nextSibling; + } while (oldDom != null && oldDom.nodeType === 8); + + return oldDom; } /** diff --git a/test/browser/hydrate.test.js b/test/browser/hydrate.test.js index 0b23c6f12c..b03c0e2a66 100644 --- a/test/browser/hydrate.test.js +++ b/test/browser/hydrate.test.js @@ -50,11 +50,11 @@ describe('hydrate()', () => { beforeEach(() => { scratch = setupScratch(); attributesSpy = spyOnElementAttributes(); + clearLog(); }); afterEach(() => { teardown(scratch); - clearLog(); }); it('should reuse existing DOM', () => { @@ -92,6 +92,7 @@ describe('hydrate()', () => { scratch ); expect(scratch.innerHTML).to.equal('
01
'); + expect(getLog()).to.deep.equal(['Comment.remove()']); }); it('should reuse existing DOM when given components', () => { @@ -458,5 +459,13 @@ describe('hydrate()', () => { scratch.innerHTML = 'hello foo
'; hydrate(hello {'foo'}
, scratch); expect(scratch.innerHTML).to.equal('hello foo
'); + expect(getLog()).to.deep.equal(['Comment.remove()']); + }); + + it('should skip over multiple comment nodes', () => { + scratch.innerHTML = 'hello foo
'; + hydrate(hello {'foo'}
, scratch); + expect(scratch.innerHTML).to.equal('hello foo
'); + expect(getLog()).to.deep.equal(['Comment.remove()', 'Comment.remove()']); }); });