Skip to main content

Bug Tracker

Side navigation

#14990 closed bug (notabug)

Opened April 11, 2014 11:36AM UTC

Closed April 11, 2014 12:39PM UTC

jquery 1.11 not working on objects with attribute .length = 0

Reported by: f.ludwig@greyrook.com 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)

Attachments (0)
Change History (2)

Changed April 11, 2014 12:13PM UTC by anonymous comment:1

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/

Changed April 11, 2014 12:39PM UTC by dmethvin comment:2

resolution: → notabug
status: newclosed

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