Bug Tracker

Opened 12 years ago

Closed 12 years ago

#9287 closed bug (patchwelcome)

Negative :eq() in IE does not return null

Reported by: Motty Owned by:
Priority: low Milestone: 1.next
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 (http://jsfiddle.net/TuRNp/7/) of the problem. Test it in IE7 & IE8 (IE9 in compatibility mode will work in testing this) using jQuery 1.3.2+

Change History (1)

comment:1 Changed 12 years ago by addyosmani

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 :)

Note: See TracTickets for help on using tickets.