Skip to content

Commit 52aff3c

Browse files
committed
All: Rewrite all :eq usage to .eq()
1 parent 33fba53 commit 52aff3c

File tree

10 files changed

+77
-76
lines changed

10 files changed

+77
-76
lines changed

demos/position/cycler.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@
4949
});
5050
}
5151

52-
left( $( "img:eq(0)" ) );
53-
center( $( "img:eq(1)" ) );
54-
right( $( "img:eq(2)" ) );
52+
left( $( "img" ).eq( 0 ) );
53+
center( $( "img" ).eq( 1 ) );
54+
right( $( "img" ).eq( 2 ) );
5555

5656
function animate( to ) {
5757
$( this ).stop( true, false ).animate( to );
5858
}
5959
function next( event ) {
6060
event.preventDefault();
61-
center( $( "img:eq(2)" ), animate );
62-
left( $( "img:eq(1)" ), animate );
63-
right( $( "img:eq(0)" ).appendTo( "#container" ) );
61+
center( $( "img" ).eq( 2 ), animate );
62+
left( $( "img" ).eq( 1 ), animate );
63+
right( $( "img" ).eq( 0 ).appendTo( "#container" ) );
6464
}
6565
function previous( event ) {
6666
event.preventDefault();
67-
center( $( "img:eq(0)" ), animate );
68-
right( $( "img:eq(1)" ), animate );
69-
left( $( "img:eq(2)" ).prependTo( "#container" ) );
67+
center( $( "img" ).eq( 0 ), animate );
68+
right( $( "img" ).eq( 1 ), animate );
69+
left( $( "img" ).eq( 2 ).prependTo( "#container" ) );
7070
}
7171
$( "#previous" ).on( "click", previous );
7272
$( "#next" ).on( "click", next );
@@ -76,9 +76,9 @@
7676
});
7777

7878
$( window ).on( "resize", function() {
79-
left( $( "img:eq(0)" ), animate );
80-
center( $( "img:eq(1)" ), animate );
81-
right( $( "img:eq(2)" ), animate );
79+
left( $( "img" ).eq( 0 ), animate );
80+
center( $( "img" ).eq( 1 ), animate );
81+
right( $( "img" ).eq( 2 ), animate );
8282
});
8383
</script>
8484
</head>

tests/unit/accordion/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( typ
3939
QUnit.test( "handle click on header-descendant", function( assert ) {
4040
assert.expect( 1 );
4141
var element = $( "#navigation" ).accordion();
42-
$( "#navigation h2:eq(1) a" ).trigger( "click" );
42+
$( "#navigation h2" ).eq( 1 ).find( "a" ).trigger( "click" );
4343
state( assert, element, 0, 1, 0 );
4444
} );
4545

tests/unit/datepicker/core.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,25 @@ QUnit.test( "baseStructure", function( assert ) {
5555
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure - header division" );
5656
assert.equal( header.children().length, 3, "Structure - header child count" );
5757
assert.ok( header.children().first().is( "a.ui-datepicker-prev" ) && header.children().first().html() !== "", "Structure - prev link" );
58-
assert.ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-next" ) && header.children( ":eq(1)" ).html() !== "", "Structure - next link" );
58+
assert.ok( header.children().eq( 1 ).is( "a.ui-datepicker-next" ) && header.children().eq ( 1 ).html() !== "", "Structure - next link" );
5959

6060
title = header.children().last();
6161
assert.ok( title.is( "div.ui-datepicker-title" ) && title.html() !== "", "Structure - title division" );
6262
assert.equal( title.children().length, 2, "Structure - title child count" );
6363
assert.ok( title.children().first().is( "span.ui-datepicker-month" ) && title.children().first().text() !== "", "Structure - month text" );
6464
assert.ok( title.children().last().is( "span.ui-datepicker-year" ) && title.children().last().text() !== "", "Structure - year text" );
6565

66-
table = dp.children( ":eq(1)" );
66+
table = dp.children().eq( 1 );
6767
assert.ok( table.is( "table.ui-datepicker-calendar" ), "Structure - month table" );
6868
assert.ok( table.children().first().is( "thead" ), "Structure - month table thead" );
6969

7070
thead = table.children().first().children().first();
7171
assert.ok( thead.is( "tr" ), "Structure - month table title row" );
7272
assert.equal( thead.find( "th" ).length, 7, "Structure - month table title cells" );
73-
assert.ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure - month table body" );
74-
assert.ok( table.children( ":eq(1)" ).children( "tr" ).length >= 4, "Structure - month table week count" );
73+
assert.ok( table.children().eq( 1 ).is( "tbody" ), "Structure - month table body" );
74+
assert.ok( table.children().eq( 1 ).children( "tr" ).length >= 4, "Structure - month table week count" );
7575

76-
week = table.children( ":eq(1)" ).children().first();
76+
week = table.children().eq( 1 ).children().first();
7777
assert.ok( week.is( "tr" ), "Structure - month table week row" );
7878
assert.equal( week.children().length, 7, "Structure - week child count" );
7979
assert.ok( week.children().first().is( "td.ui-datepicker-week-end" ), "Structure - month table first day cell" );
@@ -119,10 +119,10 @@ QUnit.test( "baseStructure", function( assert ) {
119119
child = dp.children().first();
120120
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2] - first month division" );
121121

122-
child = dp.children( ":eq(1)" );
122+
child = dp.children().eq( 1 );
123123
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2] - second month division" );
124124

125-
child = dp.children( ":eq(2)" );
125+
child = dp.children().eq( 2 );
126126
assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2] - row break" );
127127
assert.ok( dp.is( ".ui-datepicker-multi-2" ), "Structure multi [2] - multi-2" );
128128

@@ -155,19 +155,19 @@ QUnit.test( "baseStructure", function( assert ) {
155155
child = dp.children().first();
156156
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - first month division" );
157157

158-
child = dp.children( ":eq(1)" );
158+
child = dp.children().eq( 1 );
159159
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - second month division" );
160160

161-
child = dp.children( ":eq(2)" );
161+
child = dp.children().eq( 2 );
162162
assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
163163

164-
child = dp.children( ":eq(3)" );
164+
child = dp.children().eq( 3 );
165165
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - third month division" );
166166

167-
child = dp.children( ":eq(4)" );
167+
child = dp.children().eq( 4 );
168168
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - fourth month division" );
169169

170-
child = dp.children( ":eq(5)" );
170+
child = dp.children().eq( 5 );
171171
assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
172172

173173
inp.datepicker( "hide" ).datepicker( "destroy" );
@@ -185,10 +185,10 @@ QUnit.test( "baseStructure", function( assert ) {
185185
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure inline - header division" );
186186
assert.equal( header.children().length, 3, "Structure inline - header child count" );
187187

188-
table = dp.children( ":eq(1)" );
188+
table = dp.children().eq( 1 );
189189
assert.ok( table.is( "table.ui-datepicker-calendar" ), "Structure inline - month table" );
190190
assert.ok( table.children().first().is( "thead" ), "Structure inline - month table thead" );
191-
assert.ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure inline - month table body" );
191+
assert.ok( table.children().eq( 1 ).is( "tbody" ), "Structure inline - month table body" );
192192

193193
inl.datepicker( "destroy" );
194194

@@ -202,10 +202,10 @@ QUnit.test( "baseStructure", function( assert ) {
202202
child = dp.children().first();
203203
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure inline multi - first month division" );
204204

205-
child = dp.children( ":eq(1)" );
205+
child = dp.children().eq( 1 );
206206
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure inline multi - second month division" );
207207

208-
child = dp.children( ":eq(2)" );
208+
child = dp.children().eq( 2 );
209209
assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure inline multi - row break" );
210210

211211
inl.datepicker( "destroy" );
@@ -233,7 +233,7 @@ QUnit.test( "customStructure", function( assert ) {
233233
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure RTL - header division" );
234234
assert.equal( header.children().length, 3, "Structure RTL - header child count" );
235235
assert.ok( header.children().first().is( "a.ui-datepicker-next" ), "Structure RTL - prev link" );
236-
assert.ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-prev" ), "Structure RTL - next link" );
236+
assert.ok( header.children().eq( 1 ).is( "a.ui-datepicker-prev" ), "Structure RTL - next link" );
237237

238238
panel = dp.children().last();
239239
assert.ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure RTL - button division" );

tests/unit/datepicker/options.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -710,82 +710,82 @@ QUnit.test( "daylightSaving", function( assert ) {
710710

711711
// Australia, Sydney - AM change, southern hemisphere
712712
inp.val( "04/01/2008" ).datepicker( "show" );
713-
$( ".ui-datepicker-calendar td:eq(6) a", dp ).simulate( "click" );
713+
$( ".ui-datepicker-calendar td", dp ).eq( 6 ).find( "a" ).simulate( "click" );
714714
assert.equal( inp.val(), "04/05/2008", "Daylight saving - Australia 04/05/2008" );
715715
inp.val( "04/01/2008" ).datepicker( "show" );
716-
$( ".ui-datepicker-calendar td:eq(7) a", dp ).simulate( "click" );
716+
$( ".ui-datepicker-calendar td", dp ).eq( 7 ).find( "a" ).simulate( "click" );
717717
assert.equal( inp.val(), "04/06/2008", "Daylight saving - Australia 04/06/2008" );
718718
inp.val( "04/01/2008" ).datepicker( "show" );
719-
$( ".ui-datepicker-calendar td:eq(8) a", dp ).simulate( "click" );
719+
$( ".ui-datepicker-calendar td", dp ).eq( 8 ).find( "a" ).simulate( "click" );
720720
assert.equal( inp.val(), "04/07/2008", "Daylight saving - Australia 04/07/2008" );
721721
inp.val( "10/01/2008" ).datepicker( "show" );
722-
$( ".ui-datepicker-calendar td:eq(6) a", dp ).simulate( "click" );
722+
$( ".ui-datepicker-calendar td", dp ).eq( 6 ).find( "a" ).simulate( "click" );
723723
assert.equal( inp.val(), "10/04/2008", "Daylight saving - Australia 10/04/2008" );
724724
inp.val( "10/01/2008" ).datepicker( "show" );
725-
$( ".ui-datepicker-calendar td:eq(7) a", dp ).simulate( "click" );
725+
$( ".ui-datepicker-calendar td", dp ).eq( 7 ).find( "a" ).simulate( "click" );
726726
assert.equal( inp.val(), "10/05/2008", "Daylight saving - Australia 10/05/2008" );
727727
inp.val( "10/01/2008" ).datepicker( "show" );
728-
$( ".ui-datepicker-calendar td:eq(8) a", dp ).simulate( "click" );
728+
$( ".ui-datepicker-calendar td", dp ).eq( 8 ).find( "a" ).simulate( "click" );
729729
assert.equal( inp.val(), "10/06/2008", "Daylight saving - Australia 10/06/2008" );
730730

731731
// Brasil, Brasilia - midnight change, southern hemisphere
732732
inp.val( "02/01/2008" ).datepicker( "show" );
733-
$( ".ui-datepicker-calendar td:eq(20) a", dp ).simulate( "click" );
733+
$( ".ui-datepicker-calendar td", dp ).eq( 20 ).find( "a" ).simulate( "click" );
734734
assert.equal( inp.val(), "02/16/2008", "Daylight saving - Brasil 02/16/2008" );
735735
inp.val( "02/01/2008" ).datepicker( "show" );
736-
$( ".ui-datepicker-calendar td:eq(21) a", dp ).simulate( "click" );
736+
$( ".ui-datepicker-calendar td", dp ).eq( 21 ).find( "a" ).simulate( "click" );
737737
assert.equal( inp.val(), "02/17/2008", "Daylight saving - Brasil 02/17/2008" );
738738
inp.val( "02/01/2008" ).datepicker( "show" );
739-
$( ".ui-datepicker-calendar td:eq(22) a", dp ).simulate( "click" );
739+
$( ".ui-datepicker-calendar td", dp ).eq( 22 ).find( "a" ).simulate( "click" );
740740
assert.equal( inp.val(), "02/18/2008", "Daylight saving - Brasil 02/18/2008" );
741741
inp.val( "10/01/2008" ).datepicker( "show" );
742-
$( ".ui-datepicker-calendar td:eq(13) a", dp ).simulate( "click" );
742+
$( ".ui-datepicker-calendar td", dp ).eq( 13 ).find( "a" ).simulate( "click" );
743743
assert.equal( inp.val(), "10/11/2008", "Daylight saving - Brasil 10/11/2008" );
744744
inp.val( "10/01/2008" ).datepicker( "show" );
745-
$( ".ui-datepicker-calendar td:eq(14) a", dp ).simulate( "click" );
745+
$( ".ui-datepicker-calendar td", dp ).eq( 14 ).find( "a" ).simulate( "click" );
746746
assert.equal( inp.val(), "10/12/2008", "Daylight saving - Brasil 10/12/2008" );
747747
inp.val( "10/01/2008" ).datepicker( "show" );
748-
$( ".ui-datepicker-calendar td:eq(15) a", dp ).simulate( "click" );
748+
$( ".ui-datepicker-calendar td", dp ).eq( 15 ).find( "a" ).simulate( "click" );
749749
assert.equal( inp.val(), "10/13/2008", "Daylight saving - Brasil 10/13/2008" );
750750

751751
// Lebanon, Beirut - midnight change, northern hemisphere
752752
inp.val( "03/01/2008" ).datepicker( "show" );
753-
$( ".ui-datepicker-calendar td:eq(34) a", dp ).simulate( "click" );
753+
$( ".ui-datepicker-calendar td", dp ).eq( 34 ).find( "a" ).simulate( "click" );
754754
assert.equal( inp.val(), "03/29/2008", "Daylight saving - Lebanon 03/29/2008" );
755755
inp.val( "03/01/2008" ).datepicker( "show" );
756-
$( ".ui-datepicker-calendar td:eq(35) a", dp ).simulate( "click" );
756+
$( ".ui-datepicker-calendar td", dp ).eq( 35 ).find( "a" ).simulate( "click" );
757757
assert.equal( inp.val(), "03/30/2008", "Daylight saving - Lebanon 03/30/2008" );
758758
inp.val( "03/01/2008" ).datepicker( "show" );
759-
$( ".ui-datepicker-calendar td:eq(36) a", dp ).simulate( "click" );
759+
$( ".ui-datepicker-calendar td", dp ).eq( 36 ).find( "a" ).simulate( "click" );
760760
assert.equal( inp.val(), "03/31/2008", "Daylight saving - Lebanon 03/31/2008" );
761761
inp.val( "10/01/2008" ).datepicker( "show" );
762-
$( ".ui-datepicker-calendar td:eq(27) a", dp ).simulate( "click" );
762+
$( ".ui-datepicker-calendar td", dp ).eq( 27 ).find( "a" ).simulate( "click" );
763763
assert.equal( inp.val(), "10/25/2008", "Daylight saving - Lebanon 10/25/2008" );
764764
inp.val( "10/01/2008" ).datepicker( "show" );
765-
$( ".ui-datepicker-calendar td:eq(28) a", dp ).simulate( "click" );
765+
$( ".ui-datepicker-calendar td", dp ).eq( 28 ).find( "a" ).simulate( "click" );
766766
assert.equal( inp.val(), "10/26/2008", "Daylight saving - Lebanon 10/26/2008" );
767767
inp.val( "10/01/2008" ).datepicker( "show" );
768-
$( ".ui-datepicker-calendar td:eq(29) a", dp ).simulate( "click" );
768+
$( ".ui-datepicker-calendar td", dp ).eq( 29 ).find( "a" ).simulate( "click" );
769769
assert.equal( inp.val(), "10/27/2008", "Daylight saving - Lebanon 10/27/2008" );
770770

771771
// US, Eastern - AM change, northern hemisphere
772772
inp.val( "03/01/2008" ).datepicker( "show" );
773-
$( ".ui-datepicker-calendar td:eq(13) a", dp ).simulate( "click" );
773+
$( ".ui-datepicker-calendar td", dp ).eq( 13 ).find( "a" ).simulate( "click" );
774774
assert.equal( inp.val(), "03/08/2008", "Daylight saving - US 03/08/2008" );
775775
inp.val( "03/01/2008" ).datepicker( "show" );
776-
$( ".ui-datepicker-calendar td:eq(14) a", dp ).simulate( "click" );
776+
$( ".ui-datepicker-calendar td", dp ).eq( 14 ).find( "a" ).simulate( "click" );
777777
assert.equal( inp.val(), "03/09/2008", "Daylight saving - US 03/09/2008" );
778778
inp.val( "03/01/2008" ).datepicker( "show" );
779-
$( ".ui-datepicker-calendar td:eq(15) a", dp ).simulate( "click" );
779+
$( ".ui-datepicker-calendar td", dp ).eq( 15 ).find( "a" ).simulate( "click" );
780780
assert.equal( inp.val(), "03/10/2008", "Daylight saving - US 03/10/2008" );
781781
inp.val( "11/01/2008" ).datepicker( "show" );
782-
$( ".ui-datepicker-calendar td:eq(6) a", dp ).simulate( "click" );
782+
$( ".ui-datepicker-calendar td", dp ).eq( 6 ).find( "a" ).simulate( "click" );
783783
assert.equal( inp.val(), "11/01/2008", "Daylight saving - US 11/01/2008" );
784784
inp.val( "11/01/2008" ).datepicker( "show" );
785-
$( ".ui-datepicker-calendar td:eq(7) a", dp ).simulate( "click" );
785+
$( ".ui-datepicker-calendar td", dp ).eq( 7 ).find( "a" ).simulate( "click" );
786786
assert.equal( inp.val(), "11/02/2008", "Daylight saving - US 11/02/2008" );
787787
inp.val( "11/01/2008" ).datepicker( "show" );
788-
$( ".ui-datepicker-calendar td:eq(8) a", dp ).simulate( "click" );
788+
$( ".ui-datepicker-calendar td", dp ).eq( 8 ).find( "a" ).simulate( "click" );
789789
assert.equal( inp.val(), "11/03/2008", "Daylight saving - US 11/03/2008" );
790790
} );
791791

tests/unit/menu/core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ QUnit.test( "active menu item styling", function( assert ) {
8787
}
8888
$.ui.menu.prototype.delay = 0;
8989
var element = $( "#menu4" ).menu();
90-
var parentItem = element.children( "li:eq(1)" );
91-
var childItem = parentItem.find( "li:eq(0)" );
90+
var parentItem = element.children( "li" ).eq( 1 );
91+
var childItem = parentItem.find( "li" ).eq( 0 );
9292
element.menu( "focus", null, parentItem );
9393
setTimeout( function() {
9494
isActive( parentItem );

tests/unit/menu/helper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ return $.extend( helper, {
2727

2828
click: function( menu, item ) {
2929
lastItem = item;
30-
menu.children( ":eq(" + item + ")" )
30+
menu.children()
31+
.eq( item )
3132
.children( ".ui-menu-item-wrapper" )
3233
.trigger( "click" );
3334
}

0 commit comments

Comments
 (0)