Skip to content

Commit db75102

Browse files
committed
All: Mark positional selectors as deprecated since jQuery 3.4.0
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 gh-1144
1 parent 9e4b6b8 commit db75102

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+127
-112
lines changed

categories.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,19 @@
7171
<p>For more information, see the Release Notes/Changelog at <a href="https://blog.jquery.com/2016/06/09/jquery-3-0-final-released/">https://blog.jquery.com/2016/06/09/jquery-3-0-final-released/</a></p>
7272
]]></desc>
7373
</category>
74-
<category name="Deprecated 3.3" slug="deprecated-3.3">
74+
<category name="Deprecated 3.3" slug="deprecated-3.3">
7575
<desc><![CDATA[All the aspects of the API that were deprecated in the corresponding version of jQuery.
7676
<p>For more information, see the Release Notes/Changelog at <a href="https://blog.jquery.com/2018/01/19/jquery-3-3-0-a-fragrant-bouquet-of-deprecations-and-is-that-a-new-feature/">https://blog.jquery.com/2018/01/19/jquery-3-3-0-a-fragrant-bouquet-of-deprecations-and-is-that-a-new-feature/</a></p>
7777
]]></desc>
7878
</category>
79+
<category name="Deprecated 3.4" slug="deprecated-3.4">
80+
<desc><![CDATA[All the aspects of the API that were deprecated in the corresponding version of jQuery.
81+
<p>For more information, see the Release Notes/Changelog at <a href="https://blog.jquery.com/2019/04/10/jquery-3-4-0-released/">https://blog.jquery.com/2019/04/10/jquery-3-4-0-released/</a></p>
82+
]]></desc>
83+
</category>
7984
</category>
8085
<category name="Dimensions" slug="dimensions">
81-
<desc><![CDATA[These methods are used to get and set the CSS dimensions for the various properties.]]></desc>
86+
<desc><![CDATA[These methods are used to get and set the CSS dimensions for the various properties.]]></desc>
8287
</category>
8388
<category name="Effects" slug="effects">
8489
<desc><![CDATA[The jQuery library provides several techniques for adding animation to a web page. These include simple, standard animations that are frequently used, and the ability to craft sophisticated custom effects.]]></desc>

entries/addClass.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ $( "p" ).last().addClass( "selected" );
6464
<example>
6565
<desc>Add the classes "selected" and "highlight" to the matched elements.</desc>
6666
<code><![CDATA[
67-
$( "p:last" ).addClass( "selected highlight" );
67+
$( "p" ).last().addClass( "selected highlight" );
6868
]]></code>
6969
<css><![CDATA[
7070
p {

entries/animate.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,12 @@ $( "#go4" ).click(function() {
249249
<desc>Animates the first div's left property and synchronizes the remaining divs, using the step function to set their left properties at each stage of the animation. </desc>
250250
<code><![CDATA[
251251
$( "#go" ).click(function() {
252-
$( ".block:first" ).animate({
252+
$( ".block" ).first().animate({
253253
left: 100
254254
}, {
255255
duration: 1000,
256256
step: function( now, fx ){
257-
$( ".block:gt(0)" ).css( "left", now );
257+
$( ".block" ).slice( 1 ).css( "left", now );
258258
}
259259
});
260260
});

entries/children.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ $( "#container" ).click(function ( event ) {
4343
var kids = $( event.target ).children();
4444
var len = kids.addClass( "hilite" ).length;
4545
46-
$( "#results span:first" ).text( len );
47-
$( "#results span:last" ).text( event.target.tagName );
46+
$( "#results span" ).first().text( len );
47+
$( "#results span" ).last().text( event.target.tagName );
4848
4949
event.preventDefault();
5050
});

entries/contextmenu.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ $( "p" ).contextmenu(function() {
5858
<example>
5959
<desc>Right click to toggle background color.</desc>
6060
<code><![CDATA[
61-
var div = $( "div:first" );
61+
var div = $( "div" ).first();
6262
div.contextmenu(function() {
6363
div.toggleClass( "contextmenu" );
6464
});

entries/data.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ $( "body" ).data(); // { foo: 52, bar: { isManual: true }, baz: [ 1, 2, 3 ] }
4040
<desc>Store then retrieve a value from the div element.</desc>
4141
<code><![CDATA[
4242
$( "div" ).data( "test", { first: 16, last: "pizza!" } );
43-
$( "span:first" ).text( $( "div" ).data( "test" ).first );
44-
$( "span:last" ).text( $( "div" ).data( "test" ).last );
43+
$( "span" ).first().text( $( "div" ).data( "test" ).first );
44+
$( "span" ).last().text( $( "div" ).data( "test" ).last );
4545
]]></code>
4646
<css><![CDATA[
4747
div {

entries/dblclick.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ $( "p" ).dblclick(function() {
7777
<example>
7878
<desc>Double click to toggle background color.</desc>
7979
<code><![CDATA[
80-
var divdbl = $( "div:first" );
80+
var divdbl = $( "div" ).first();
8181
divdbl.dblclick(function() {
8282
divdbl.toggleClass( "dbl" );
8383
});

entries/end.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jQuery.fn.showTags = function( n ) {
5151
})
5252
.get()
5353
.join( ", " );
54-
$( "b:eq( " + n + " )" ).text( tags );
54+
$( "b" ).eq( n ).text( tags );
5555
return this;
5656
};
5757

entries/eq-selector.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<entry type="selector" name="eq" return="">
2+
<entry type="selector" name="eq" return="" deprecated="3.4">
33
<title>:eq() Selector</title>
44
<signature>
55
<sample>:eq(index)</sample>
@@ -17,6 +17,7 @@
1717
</signature>
1818
<desc>Select the element at index <code>n</code> within the matched set.</desc>
1919
<longdesc>
20+
<p><strong>As of jQuery 3.4</strong>, the <code>:eq</code> pseudo-class is deprecated. Remove it from your selectors and filter the results later using <a href="/eq/"><code>.eq()</code></a>.</p>
2021
<p>The index-related selectors (<code>:eq()</code>, <code>:lt()</code>, <code>:gt()</code>, <code>:even</code>, <code>:odd</code>) filter the set of elements that have matched the expressions that precede them. They narrow the set down based on the order of the elements within this matched set. For example, if elements are first selected with a class selector (<code>.myclass</code>) and four elements are returned, these elements are given indices <code>0</code> through <code>3</code> for the purposes of these selectors.</p>
2122
<p>Note that since JavaScript arrays use <em>0-based indexing</em>, these selectors reflect that fact. This is why <code>$( ".myclass:eq(1)" )</code> selects the second element in the document with the class myclass, rather than the first. In contrast, <code>:nth-child(n)</code> uses <em>1-based indexing</em> to conform to the CSS specification.</p>
2223
<p>Prior to jQuery 1.8, the <code>:eq(index)</code> selector did <em>not</em> accept a negative value for <code>index</code> (though the <a href="/eq/"><code>.eq(index)</code></a> method did).</p>
@@ -92,4 +93,5 @@ $( "li:eq(-2)" ).addClass( "foo" )
9293
<category slug="selectors/jquery-selector-extensions"/>
9394
<category slug="version/1.0"/>
9495
<category slug="version/1.8"/>
96+
<category slug="deprecated/deprecated-3.4"/>
9597
</entry>

entries/even-selector.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<entry type="selector" name="even" return="">
2+
<entry type="selector" name="even" return="" deprecated="3.4">
33
<title>:even Selector</title>
44
<sample>:even</sample>
55
<signature>
@@ -33,4 +33,5 @@ $( "tr:even" ).css( "background-color", "#bbf" );
3333
<category slug="selectors/basic-filter-selectors"/>
3434
<category slug="selectors/jquery-selector-extensions"/>
3535
<category slug="version/1.0"/>
36+
<category slug="deprecated/deprecated-3.4"/>
3637
</entry>

0 commit comments

Comments
 (0)