Skip to content

Commit

Permalink
Merge branch 'main' into ontouchcap
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock authored Jan 2, 2024
2 parents aec15a6 + 899e9d9 commit c6f82fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
11 changes: 10 additions & 1 deletion test/browser/hydrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ describe('hydrate()', () => {
beforeEach(() => {
scratch = setupScratch();
attributesSpy = spyOnElementAttributes();
clearLog();
});

afterEach(() => {
teardown(scratch);
clearLog();
});

it('should reuse existing DOM', () => {
Expand Down Expand Up @@ -92,6 +92,7 @@ describe('hydrate()', () => {
scratch
);
expect(scratch.innerHTML).to.equal('<p><i>0</i><b>1</b></p>');
expect(getLog()).to.deep.equal(['Comment.remove()']);
});

it('should reuse existing DOM when given components', () => {
Expand Down Expand Up @@ -458,5 +459,13 @@ describe('hydrate()', () => {
scratch.innerHTML = '<p>hello <!-- c -->foo</p>';
hydrate(<p>hello {'foo'}</p>, scratch);
expect(scratch.innerHTML).to.equal('<p>hello foo</p>');
expect(getLog()).to.deep.equal(['Comment.remove()']);
});

it('should skip over multiple comment nodes', () => {
scratch.innerHTML = '<p>hello <!-- a --><!-- b -->foo</p>';
hydrate(<p>hello {'foo'}</p>, scratch);
expect(scratch.innerHTML).to.equal('<p>hello foo</p>');
expect(getLog()).to.deep.equal(['Comment.remove()', 'Comment.remove()']);
});
});

0 comments on commit c6f82fd

Please sign in to comment.