Skip to content

Commit

Permalink
Allow function children for VNodes. Fixes #154 (at least as far as Pr…
Browse files Browse the repository at this point in the history
…eact core is concerned, the remainder of compat is for preact-compat).
  • Loading branch information
developit committed Jun 6, 2016
1 parent 785e2c3 commit e2a22f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/h.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VNode } from './vnode';
import { optionsHook } from './hooks';
import { falsey, isString } from './util';
import { falsey, isFunction, isString } from './util';


const SHARED_TEMP_ARRAY = [];
Expand Down Expand Up @@ -40,7 +40,7 @@ export function h(nodeName, attributes, firstChild) {
}
for (let j=0; j<arr.length; j++) {
let child = arr[j],
simple = !falsey(child) && !(child instanceof VNode);
simple = !(falsey(child) || isFunction(child) || child instanceof VNode);
if (simple && !isString(child)) child = String(child);
if (simple && lastSimple) {
children[children.length-1] += child;
Expand Down

0 comments on commit e2a22f6

Please sign in to comment.