Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Make the Children API compatible with React #236

Merged
merged 2 commits into from
Dec 14, 2016

Conversation

linde12
Copy link
Contributor

@linde12 linde12 commented Nov 11, 2016

There were some differences to the following methods
that caused Preact to act differently than React:

  • Children.map
  • Children.forEach
  • Children.count

There were some differences to the following methods
that caused Preact to act differently than React:

- Children.map
- Children.forEach
- Children.count
children = Children.toArray(children);
if (ctx && ctx!==children) fn = fn.bind(ctx);
children.forEach(fn);
},
count(children) {
children = Children.toArray(children);
return children.length;
let count = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we skip the iteration here and just do something like this?

return children && children.length || 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, of course! Nice catch

@developit developit merged commit 8d635df into preactjs:master Dec 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants