Skip to content

Commit

Permalink
Improve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Mar 20, 2023
1 parent b4df76d commit 5242ac0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ function diffElementNodes(
// Unmount any previous children
if (oldVNode._children) {
while ((i = oldVNode._children.pop())) {
// Setting textContent on the dom element already unmounted all DOM
// nodes of the previous children
// Setting textContent on the dom element will unmount all DOM nodes
// of the previous children, so we don't need to remove DOM in this
// call to unmount
unmount(i, oldVNode, true);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1208,16 +1208,16 @@ describe('render()', () => {
sinon.spy(Child.prototype, 'componentDidMount');
sinon.spy(Child.prototype, 'componentWillUnmount');

function App({ condition = false }) {
return <div>{condition ? 'Hello' : [<Child />, <span>b</span>]}</div>;
function App({ textChild = false }) {
return <div>{textChild ? 'Hello' : [<Child />, <span>b</span>]}</div>;
}

render(<App />, scratch);
expect(scratch.innerHTML).to.equal('<div>Child<span>b</span></div>');
expect(proto.componentDidMount).to.have.been.calledOnce;
expect(proto.componentWillUnmount).to.have.not.been.called;

render(<App condition />, scratch);
render(<App textChild />, scratch);
expect(scratch.innerHTML).to.equal('<div>Hello</div>');
expect(proto.componentDidMount).to.have.been.calledOnce;
expect(proto.componentWillUnmount).to.have.been.calledOnce;
Expand Down

0 comments on commit 5242ac0

Please sign in to comment.