Opened 9 years ago
Closed 9 years ago
#14990 closed bug (notabug)
jquery 1.11 not working on objects with attribute .length = 0
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.11.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If there is an object that does got an attribute "length" which value is 0 jquery can not be used on it.
jQuery({length:0})
[]
jQuery({length:1})
[Object]
This is unexpected behaviour, horrible to debug and the source code does not provide a reasoning behind the check. (see function isArrayLike)
Change History (2)
comment:1 Changed 9 years ago by
comment:2 Changed 9 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
That is the way it's supposed to work. https://api.jquery.com/jQuery.each/
I've submitted a docs issue, feel free to make a pull request. https://github.com/jquery/api.jquery.com/issues/473
Note: See
TracTickets for help on using
tickets.
I was asked on IRC to provide examples how this can turn into a problem here are two examples:
http://jsfiddle.net/E2z8T/ http://jsfiddle.net/C9QJq/