Skip to content

Conversation

@mgol
Copy link
Member

@mgol mgol commented Aug 29, 2019

Positional selectors: :first, :last, :eq, :even, :odd, :lt, :gt, and :nth are deprecated since jQuery 3.4.0. This is now reflected in the docs & most deprecated pseudo-classes are not used in examples on other API pages.

The only exception is :even & :odd which are still used on some pages. I wasn't sure whether I should migrate them to a custom implementation using .filter() or whether we want .even() & .odd() in Core. I did a quick implementation to check the size impact & that would add 25 bytes to the gzipped file.

Fixes gh-1144

@mgol mgol requested review from dmethvin and timmywil August 29, 2019 23:37
@mgol mgol force-pushed the pos-deprecation branch 2 times, most recently from 88c014c to db75102 Compare August 29, 2019 23:53
Positional selectors: :first, :last, :eq, :even, :odd, :lt, :gt, and :nth are
deprecated since jQuery 3.4.0. This is now reflected in the docs & deprecated
pseudo-classes are not used in examples on other API pages.

Fixes jquerygh-1144
@mgol mgol force-pushed the pos-deprecation branch from db75102 to 2d61a88 Compare August 30, 2019 10:34
Copy link
Member

@dmethvin dmethvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you caught all the usage, thanks! I don't know how common the even/odd usage is. We should put it into Migrate for sure. If we don't put it in core we could just mention the simple implementation of each in the Migrate warning and people can add that to their code.

@mgol
Copy link
Member Author

mgol commented Sep 2, 2019

This is the implementation that adds +25 bytes: mgol/jquery@f454097

	even: function() {
		return this.filter( function( i ) {
			return ( i + 1 ) % 2;
		} );
	},

	odd: function() {
		return this.filter( function( i ) {
			return i % 2;
		} );
	},

@mgol
Copy link
Member Author

mgol commented Sep 2, 2019

OK, I'm going to merge it; we can discuss the .even()/.odd() issue separately.

@mgol mgol merged commit eb5c900 into jquery:master Sep 2, 2019
@mgol mgol deleted the pos-deprecation branch September 2, 2019 16:12
@mgol
Copy link
Member Author

mgol commented Sep 2, 2019

I extracted the :even/:odd issue to #1147.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Document that positional selectors are deprecated since jQuery 3.4.0

2 participants