Open ishenli opened 6 years ago
Hi,@developit can you merge this PR?
I'm still confused how it's possible to end up with props.children
containing values like null
or undefined
. Preact strips those out - see this demo:
https://jsfiddle.net/developit/z97ua3m3/
So it would seem that, regardless of whether this PR is merged or not, Preact will still have removed the empty values prior to map()
running, right?
Setting that aside, I think this could be simplified a bit? Something like:
map(children, fn, ctx) {
if (children == null) return null;
children = Children.toArray(children);
if (ctx) fn = fn.bind(ctx);
return children.filter(Boolean).map(fn).filter(Boolean);
}
@developit children property can contain null
values. I created simple example for preact@8.3.1
: https://codesandbox.io/s/wwnx5q1277?expanddevtools=1
ref: https://github.com/developit/preact-compat/issues/419
When the new child is null, should ignore , like React