-
Notifications
You must be signed in to change notification settings - Fork 20.6k
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
isArrayLike
no longer fails gracefully for null and undefined from 1.11.1 to 1.11.3
#2267
Comments
This is basically a dup of #2242, we don't guarantee that invalid inputs will be silently ignored. |
Agreed. |
@dmethvin is right, but I'm starting to wonder if it would be nice if we failed silently here. The string case was more obscure, but I would expect that changing the behavior for |
@timmywil agreed. Also, other implementations like lodash's |
We use |
For the cases of numbers and strings, I agree with this, but passing variables that may be |
That is a good point, but only if we also document that |
isArrayLike
no longer fails gracefully for numbers, null, and undefined from 1.11.1 to 1.11.3isArrayLike
no longer fails gracefully for null and undefined from 1.11.1 to 1.11.3
So if an object that has no length attribute is passed into this function, how should this function behave? |
@uptoeleven This function is not exposed publicly so you need to ask about a specific public method that you use. And since those methods, like jQuery.each are usually documented so that they accept an array, an object and (but only in jQuery 3.0.0) |
in 1.11.1, isArrayLike looks like this:
in 1.11.3, it looks like this:
"length" in obj
produces the errorTypeError: Cannot use 'in' operator to search for 'length' in 6
whenobj === 6
. Similarly whenobj
is aundefined
ornull
. This causes, specifically$.each
to fail when you accidentally put in a numerical value forobj
. Not sure if this is an issue, but in 1.11.1, nothing failed whenobj
was accidentally a number. This caused some tests to fail that we've fixed. Thought I'd mention it.The text was updated successfully, but these errors were encountered: