Bug Tracker

Opened 8 years ago

Closed 8 years ago

#8831 closed bug (invalid)

sizzle.getText in ie trying to access the zeroth element of an empty array is an error

Reported by: anonymous Owned by:
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:

Description

var arr = []; for (var i = 0; arr[i]; i++) {

alert("here");

}

Change History (1)

comment:1 Changed 8 years ago by dmethvin

Resolution: invalid
Status: newclosed

That's done because of an issue with the .length property on some browsers. If there are no elements in the collection then arr[0] will be undefined and the loop will not be entered. Did you try your code sample? It seems to work fine for me.

http://jsfiddle.net/dmethvin/MrdNa/

Note: See TracTickets for help on using tickets.