diff --git a/src/diff/children.js b/src/diff/children.js index 40a038722f..369014af39 100644 --- a/src/diff/children.js +++ b/src/diff/children.js @@ -212,7 +212,7 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) { null, null ); - } else if (childVNode._depth > 0) { + } else if (childVNode.constructor === undefined && childVNode._depth > 0) { // VNode is already in use, clone it. This can happen in the following // scenario: // const reuse =
diff --git a/test/browser/components.test.js b/test/browser/components.test.js index 1dfb7a55d9..2c1a80c35d 100644 --- a/test/browser/components.test.js +++ b/test/browser/components.test.js @@ -1897,6 +1897,28 @@ describe('Components', () => { expect(unmounted).to.equal(',0,1,2,3'); }); + it('should ignore invalid vnodes in children array', () => { + /** @type { (() => void)} */ + let update; + + const obj = { a: 10, b: 'hello' }; + class App extends Component { + constructor(props) { + super(props); + this.state = { i: 0 }; + update = () => this.setState({ i: this.state.i + 1 }); + } + + render() { + return

{obj}

; + } + } + + render(, scratch); + update(); + expect(() => rerender()).not.to.throw(); + }); + describe('c.base', () => { /* eslint-disable lines-around-comment */ /** @type {import('../../src').Component} */