Bug Tracker

Modify

Ticket #9287 (closed bug: patchwelcome)

Opened 2 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

Description

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

comment:1 Changed 2 years ago by addyosmani

  • Priority changed from undecided to low
  • Resolution set to patchwelcome
  • Status changed from new to closed
  • Component changed from unfiled to selector

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.