Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using :even/:odd in examples on other pages #1147

Open
mgol opened this issue Sep 2, 2019 · 1 comment
Open

Stop using :even/:odd in examples on other pages #1147

mgol opened this issue Sep 2, 2019 · 1 comment

Comments

@mgol
Copy link
Member

mgol commented Sep 2, 2019

PR #1145 marked all positional selectors as deprecated & removed their usage from API pages for non-deprecated APIs. The only exceptions are :even & :odd selectors as there are no tiny equivalents in jQuery APIs.

We could define an .even()/.odd() API. 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;
		} );
	},

That said, such an API would be jQuery 3.5.0+ (unless Migrate polyfills it for earlier versions as well) only and we'd have to release that 3.5.0 before 4.0.0. Something to consider.

If that's decided against then we need to rewrite existing examples using :odd/:even to use something else.

I think I'm slightly in favor of introducing these two new methods as that'd close the gap from POS selectors & it'd simplify the migration. But let's talk about it. cc @jquery/core

@mgol
Copy link
Member Author

mgol commented Sep 16, 2019

Core PR adding .even()/.odd(): jquery/jquery#4485

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

No branches or pull requests

1 participant