Bug Tracker

Opened 7 years ago

Closed 7 years ago

#14161 closed feature (notabug)

:nth() selector - removal plans?

Reported by: dsg4@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Description

There was recently a question (the first of its kind) asked about the little-known :nth() selector, used in the sizzle.js engine, which I answered.

Link to said question here - http://stackoverflow.com/questions/17382703/what-is-the-nth-pseudo-class-selector-in-jquery.

As you'll see in my answer, I included an old mailing list conversation regarding the difference between the two, and when both selectors were pointed out to be equal, John Resig responded: "Huh... I should probably nuke :nth().".

Link to said mailing list conversation here - http://www.mail-archive.com/jquery-en@googlegroups.com/msg13567.html.

I'm a little confused as to why :nth() has still not been removed considering it is seemingly exactly the same as :eq(). Are there any plans to remove it in the future? If not, why?

Side query: It appears a jsPerf was made to compare and confirm the two selectors were exactly the same; all's well when tested in desktop browsers, however there seems to be differences in speed in mobile browsers - surely those tests just anomalies? or is there anything behind it?

Link to said jsPerf - http://jsperf.com/eq-vs-nth

Change History (2)

comment:1 Changed 7 years ago by dmethvin

That jsperf shows there isn't any real difference. Don't get hung up on small differences.

It doesn't really buy us anything in size or performance to remove :nth so I'd be inclined to leave it in. All we'll end up doing is breaking someone's code.

Right now :nth doesn't seem to be documented, it would be worth adding an entry so that we can add the warnings used in all jQuery selector extensions.

comment:2 Changed 7 years ago by timmywil

Resolution: notabug
Status: newclosed

It's just an alias. It's not documented by jQuery (because there's :eq), but it's documented by Sizzle.

Note: See TracTickets for help on using tickets.