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

has doesn't work with sparse arrays #73

Closed
mxdubois opened this issue Aug 26, 2016 · 4 comments
Closed

has doesn't work with sparse arrays #73

mxdubois opened this issue Aug 26, 2016 · 4 comments
Labels

Comments

@mxdubois
Copy link

Hey, I've noticed that has throws an error when I try to check a nested path in a sparse array. I believe it should return false in this case.

Example:
objectPath.has({ foo: [undefined, undefined, undefined] }, 'foo.0.bar')

Throws:

 Uncaught TypeError: Cannot convert undefined or null to object(…)
 objectPath.has @ index.js:136
@vfernandestoptal
Copy link

Got the same error on an object property that has a null/undefined value, like

objectPath.has({ a: null }, 'a.b')
TypeError: Cannot convert undefined or null to object
    at hasOwnProperty (native)
    at Function.objectPath.has (.../object-path/index.js:136:81)

So I think this is more general than just array.

@mariocasciaro
Copy link
Owner

Thanks for reporting this guys I'll look into this as soon as I can. In the meantime any PR is welcome...

@mariocasciaro
Copy link
Owner

Fixed in 0.11.2

@vfernandestoptal
Copy link

thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants