jquery / jquery/api.jquery.com
Stop using :even/:odd in examples on other pages
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 325
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
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: https://github.com/mgol/jquery/commit/f45409708c6f307bf923440d09f6f2fd86df9a9d
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review PR #1145 and the API-page examples that still use :odd or :even. First determine whether the proposed .even()/.odd() APIs should be introduced for jQuery 3.5.0; if not, rewrite those examples using another approach. Done means the decision is recorded and the remaining examples no longer rely on the deprecated selectors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jquery
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100