Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break tree traversal on null value #159

Merged
merged 1 commit into from
Jul 11, 2018

Conversation

normanrz
Copy link
Contributor

treeTraverse crashes when there are null values in a nested object, since Object.keys(null) (see line 40) throws an error.

This PR breaks tree traversal on null values as well as undefined values. Line 25 could also be written as:

export function treeTraverse(path = '', tree, isLeafNode, errorMessage, callback) {
  if (isLeafNode(path, tree)) {
    callback(path, tree);
  } else if (tree == null) {
    return;
  } else if (Array.isArray(tree)) {
...

@benjycui benjycui merged commit e1d1dc3 into react-component:master Jul 11, 2018
@benjycui
Copy link
Member

2.2.1

@normanrz normanrz deleted the patch-1 branch July 11, 2018 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants