Skip to content

Commit

Permalink
Add support for new String() as a child (#4152)
Browse files Browse the repository at this point in the history
Fixes #4151
  • Loading branch information
appsforartists committed Oct 9, 2023
1 parent 9c5a82e commit 600d8cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function diffChildren(
// or we are rendering a component (e.g. setState) copy the oldVNodes so it can have
// it's own DOM & etc. pointers
else if (
typeof childVNode == 'string' ||
childVNode.constructor === String ||
typeof childVNode == 'number' ||
// eslint-disable-next-line valid-typeof
typeof childVNode == 'bigint'
Expand Down
12 changes: 12 additions & 0 deletions test/browser/components.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,18 @@ describe('Components', () => {
expect(scratch.innerHTML).to.equal('42');
});

it('should render a new String()', () => {
class ConstructedStringComponent extends Component {
render() {
/* eslint-disable no-new-wrappers */
return new String('Hi from a constructed string!');
}
}

render(<ConstructedStringComponent />, scratch);
expect(scratch.innerHTML).to.equal('Hi from a constructed string!');
});

it('should render null as empty string', () => {
class NullComponent extends Component {
render() {
Expand Down

0 comments on commit 600d8cf

Please sign in to comment.