Skip to content

Commit 3abc062

Browse files
committed
backport #3919
1 parent a45ac8a commit 3abc062

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/create-element.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ export function createElement(type, props, children) {
5656
*/
5757
export function normalizeToVNode(childVNode) {
5858
let type = typeof childVNode;
59-
if (childVNode == null || type == 'boolean') {
59+
if (
60+
childVNode == null ||
61+
type == 'boolean' ||
62+
typeof childVNode == 'function'
63+
) {
6064
return null;
6165
}
6266

test/browser/render.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,16 @@ describe('render()', () => {
11771177
expect(scratch.querySelector('p').contentEditable).to.equal('false');
11781178
});
11791179

1180+
it('should not render children when rerendering a function child', () => {
1181+
const icon = () => {};
1182+
1183+
render(<div>{icon}</div>, scratch);
1184+
expect(scratch.innerHTML).to.equal('<div></div>');
1185+
1186+
render(<div>{icon}</div>, scratch);
1187+
expect(scratch.innerHTML).to.equal('<div></div>');
1188+
});
1189+
11801190
// #3060
11811191
it('should reset tabindex on undefined/null', () => {
11821192
const defaultValue = isIE11 ? 0 : -1;

0 commit comments

Comments
 (0)