Skip to main content

Bug Tracker

Side navigation

#9287 closed bug (patchwelcome)

Opened May 14, 2011 05:39PM UTC

Closed May 18, 2011 07:25PM UTC

Negative :eq() in IE does not return null

Reported by: Motty Owned by:
Priority: low Milestone:
Component: selector Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

I posted this bug report before #9022, but it was mistakenly closed because the ".eq()" function was examined and not the ":eq()" selector, which acts completely different!

In pre-IE9 browsers if a negative number is inside of the ":eq(n)" selector it returns ":eq(0)" as an object and not null. This occurs in pre-IE9 browsers only and in all jQuery versions after 1.2.6.

Here is a demo ( of the problem. Test it in IE7 & IE8 (IE9 in compatibility mode will work in testing this) using jQuery 1.3.2+

Attachments (0)
Change History (1)

Changed May 18, 2011 07:25PM UTC by addyosmani comment:1

component: unfiledselector
priority: undecidedlow
resolution: → patchwelcome
status: newclosed

Thanks for submitting a ticket to the jQuery Project!. We appreciate you taking the time to put together a test case for us to evaluate.

Reviewing your previous submission and comparing it against this one, I'll expand on the comments previously made by rwaldron. Please note that unlike .eq(), :eq() does not accept negative numbers and should not be used with negative integers in this context. This is a point reflected in our documentation:

''Unlike the .eq(index) method, the :eq(index) selector does not accept a negative value for index. For example, while $('li').eq(-1) selects the last li element, $('li:eq(-1)') selects nothing.''

In many situations, although we do handle the provision of a consistent return value, we also encourage users to not pass invalid or unsupported values for parameters into jQuery methods. It's simply unfeasible for us to handle every case of this. Based on this, I'll be closing your ticket as patchwelcome.

Should another member of the team feel that this ticket should however be fixed, please feel free to re-open :)