Skip to main content

Bug Tracker

Side navigation

#8008 closed bug (invalid)

Opened January 19, 2011 09:32AM UTC

Closed January 19, 2011 05:18PM UTC

function each launch an error when the object is empty on verion 1.4.4

Reported by: Owned by:
Priority: low Milestone:
Component: misc Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

The expression $.each(data, function(key, value) {}); launch an error in case of data is empty or null:

On Google Chrome 10 the error is: function length can´t be applied to a null value

On Mozilla Firefox 3.6.13 the error es: (jquery minified) variable j is null; (standard jquery) variable object is null

I think it not happend on jquery 1.4 cuz error appear only when I update to 1.4.4

Attachments (0)
Change History (5)

Changed January 19, 2011 03:46PM UTC by addyosmani comment:1

owner: →
status: newpending

Thanks for submitting a ticket to the jQuery Bug Tracker!. Please provide a reduced test case that reproduces the issue to help us fully evaluate your ticket.

Changed January 19, 2011 04:30PM UTC by comment:2

status: pendingnew

Itís imposible reproduce exactly on jsFiddle cuz they validate when isn't a correct json

My case is like

But you cann´t see the error in that url so you can see the in something like this

Hoping to be usefull

Changed January 19, 2011 04:43PM UTC by danheberden comment:3

Why would you send it an invalid object?

Changed January 19, 2011 04:57PM UTC by comment:4

the point isn´t that I send an invalid object (it was a problem in my code) the point is in jquery 1.4 the script don´t launch an error cuz the object is empty or null but in 1.4.4 the script launch an unexpected error, thats the point

Changed January 19, 2011 05:18PM UTC by jitter comment:5

component: unfiledmisc
priority: undecidedlow
resolution: → invalid
status: newclosed

This test case shows that jQuery.each always throws an error when it gets passed null as argument (in all 1.4.X versions and the current 1.5b1 release). So the behavior is consistent across versions.

Anyway this wouldn't be a bug as passing null to jQuery.each isn't a valid thing to do according to the API and is thus bound to trigger unspecified behavior or throw an exception.