Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12682 closed bug (notabug)

:eq() behavior does not match documentation

Reported by: niek.sanders@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:

Description

The selector $('foo:eq(-1)') returns the last foo, but the documentation claims this should result in an empty set.

Fiddle demonstrating behavior: http://jsfiddle.net/Gj5Qj/3/

Documentation: http://api.jquery.com/eq-selector/

Specific documentation text: "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."

Able to reproduce in both Chrome (v19) and Firefox (v11) on Linux.

Change History (3)

comment:1 Changed 7 years ago by dmethvin

Status: newopen

That was an intended change in 1.8, we wanted the method and the selector to have equivalent behavior. So yes the docs need to be updated.

comment:2 Changed 7 years ago by ajpiano

Keywords: needsdocs added
Resolution: notabug
Status: openclosed

Ported this over to https://github.com/jquery/api.jquery.com/issues/83 and closing this.

comment:3 Changed 7 years ago by mikesherov

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