Bug Tracker

Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#12241 closed bug (fixed)

Passing a negative index for :eq throws a syntax error.

Reported by: [email protected] Owned by: timmywil
Priority: low Milestone: 1.8.1
Component: selector Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:


If negative index is set for :eq a syntax error is thrown. Here is a basic selector: $("div").children(":eq(-1)") and a jsbin sample http://jsbin.com/ovurif/1/edit.

The documentation states that it is not supported but an empty set will be returned. Which unfortunately is not true with the 1.8:

"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."

Change History (6)

comment:1 Changed 11 years ago by timmywil

Component: unfiledselector
Milestone: None1.8.1
Owner: set to timmywil
Priority: undecidedlow
Status: newassigned

I don't have a problem with negative values working. We can fix that in the next patch release.

comment:2 Changed 11 years ago by dmethvin

Well, working as documented, which is to say they return nothing.

comment:3 Changed 11 years ago by timmywil

Actually, I was thinking it would be easy to make it work the same way as the method.

comment:4 Changed 10 years ago by Timmy Willison

Resolution: fixed
Status: assignedclosed

Sizzle: support negative numbers in :eq. Fixes #12241.

Changeset: fbdf8bed4fa34b6c922a287060ffaa01a55245a9

comment:5 Changed 10 years ago by dmethvin

Keywords: needsdocs added

As of 1.8.1 the :eq() selector now supports negative numbers the same way the .eq() method does.

comment:6 Changed 10 years ago by mikesherov

Keywords: needsdocs removed
Note: See TracTickets for help on using tickets.