Bug Tracker

Opened 11 years ago

Closed 11 years ago

#8008 closed bug (invalid)

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

Reported by: [email protected] Owned by: [email protected]
Priority: low Milestone: 1.next
Component: misc Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description

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

Change History (5)

comment:1 Changed 11 years ago by addyosmani

Owner: set to [email protected]
Status: newpending

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

comment:2 Changed 11 years ago by [email protected]

Status: pendingnew

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

My case is like http://jsfiddle.net/sirio3mil/ndGsV/

But you cann´t see the error in that url so you can see the in something like this http://jsfiddle.net/sirio3mil/WqHX9/

Hoping to be usefull

comment:3 Changed 11 years ago by danheberden

Why would you send it an invalid object?

comment:4 Changed 11 years ago by [email protected]

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

comment:5 Changed 11 years ago by jitter

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.

Note: See TracTickets for help on using tickets.