Skip to main content

Bug Tracker

Side navigation

#8831 closed bug (invalid)

Opened April 09, 2011 01:53PM UTC

Closed April 09, 2011 02:43PM UTC

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");

}

Attachments (0)
Change History (1)

Changed April 09, 2011 02:43PM UTC by dmethvin comment:1

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/