Skip to content

Commit af54b60

Browse files
committed
All: Rewrite all :first usage to .first()
1 parent d193d0b commit af54b60

File tree

8 files changed

+39
-39
lines changed

8 files changed

+39
-39
lines changed

tests/unit/datepicker/core.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,32 @@ QUnit.test( "baseStructure", function( assert ) {
5151
assert.ok( !dp.is( ".ui-datepicker-multi" ), "Structure - not multi-month" );
5252
assert.equal( dp.children().length, 2, "Structure - child count" );
5353

54-
header = dp.children( ":first" );
54+
header = dp.children().first();
5555
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure - header division" );
5656
assert.equal( header.children().length, 3, "Structure - header child count" );
57-
assert.ok( header.children( ":first" ).is( "a.ui-datepicker-prev" ) && header.children( ":first" ).html() !== "", "Structure - prev link" );
57+
assert.ok( header.children().first().is( "a.ui-datepicker-prev" ) && header.children().first().html() !== "", "Structure - prev link" );
5858
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" );
63-
assert.ok( title.children( ":first" ).is( "span.ui-datepicker-month" ) && title.children( ":first" ).text() !== "", "Structure - month text" );
63+
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

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

70-
thead = table.children( ":first" ).children( ":first" );
70+
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" );
7373
assert.ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure - month table body" );
7474
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" );
79-
assert.ok( week.children( ":first" ).is( "td.ui-datepicker-week-end" ), "Structure - month table first day cell" );
79+
assert.ok( week.children().first().is( "td.ui-datepicker-week-end" ), "Structure - month table first day cell" );
8080
assert.ok( week.children( ":last" ).is( "td.ui-datepicker-week-end" ), "Structure - month table second day cell" );
8181

8282
inp.datepicker( "hide" ).datepicker( "destroy" );
@@ -94,13 +94,13 @@ QUnit.test( "baseStructure", function( assert ) {
9494
} );
9595
testHelper.onFocus( inp, function() {
9696
title = dp.find( "div.ui-datepicker-title" );
97-
assert.ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure - month selector" );
97+
assert.ok( title.children().first().is( "select.ui-datepicker-month" ), "Structure - month selector" );
9898
assert.ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure - year selector" );
9999

100100
panel = dp.children( ":last" );
101101
assert.ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure - button panel division" );
102102
assert.equal( panel.children().length, 2, "Structure - button panel child count" );
103-
assert.ok( panel.children( ":first" ).is( "button.ui-datepicker-current" ), "Structure - today button" );
103+
assert.ok( panel.children().first().is( "button.ui-datepicker-current" ), "Structure - today button" );
104104
assert.ok( panel.children( ":last" ).is( "button.ui-datepicker-close" ), "Structure - close button" );
105105

106106
inp.datepicker( "hide" ).datepicker( "destroy" );
@@ -116,7 +116,7 @@ QUnit.test( "baseStructure", function( assert ) {
116116
assert.ok( dp.is( ".ui-datepicker-multi" ), "Structure multi [2] - multi-month" );
117117
assert.equal( dp.children().length, 3, "Structure multi [2] - child count" );
118118

119-
child = dp.children( ":first" );
119+
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

122122
child = dp.children( ":eq(1)" );
@@ -152,7 +152,7 @@ QUnit.test( "baseStructure", function( assert ) {
152152
assert.ok( dp.is( ".ui-datepicker-multi" ), "Structure multi - multi-month" );
153153
assert.equal( dp.children().length, 6, "Structure multi [2,2] - child count" );
154154

155-
child = dp.children( ":first" );
155+
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

158158
child = dp.children( ":eq(1)" );
@@ -181,13 +181,13 @@ QUnit.test( "baseStructure", function( assert ) {
181181
assert.ok( !dp.is( ".ui-datepicker-multi" ), "Structure inline - not multi-month" );
182182
assert.equal( dp.children().length, 2, "Structure inline - child count" );
183183

184-
header = dp.children( ":first" );
184+
header = dp.children().first();
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

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

193193
inl.datepicker( "destroy" );
@@ -199,7 +199,7 @@ QUnit.test( "baseStructure", function( assert ) {
199199
assert.ok( dp.is( ".ui-datepicker-inline" ) && dp.is( ".ui-datepicker-multi" ), "Structure inline multi - main div" );
200200
assert.equal( dp.children().length, 3, "Structure inline multi - child count" );
201201

202-
child = dp.children( ":first" );
202+
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

205205
child = dp.children( ":eq(1)" );
@@ -229,16 +229,16 @@ QUnit.test( "customStructure", function( assert ) {
229229
testHelper.onFocus( inp, function() {
230230
assert.ok( dp.is( ".ui-datepicker-rtl" ), "Structure RTL - right-to-left" );
231231

232-
header = dp.children( ":first" );
232+
header = dp.children().first();
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" );
235-
assert.ok( header.children( ":first" ).is( "a.ui-datepicker-next" ), "Structure RTL - prev link" );
235+
assert.ok( header.children().first().is( "a.ui-datepicker-next" ), "Structure RTL - prev link" );
236236
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" );
240240
assert.equal( panel.children().length, 2, "Structure RTL - button panel child count" );
241-
assert.ok( panel.children( ":first" ).is( "button.ui-datepicker-close" ), "Structure RTL - close button" );
241+
assert.ok( panel.children().first().is( "button.ui-datepicker-close" ), "Structure RTL - close button" );
242242
assert.ok( panel.children( ":last" ).is( "button.ui-datepicker-current" ), "Structure RTL - today button" );
243243

244244
inp.datepicker( "hide" ).datepicker( "destroy" );
@@ -256,10 +256,10 @@ QUnit.test( "customStructure", function( assert ) {
256256
inp.val( "02/10/2008" );
257257

258258
testHelper.onFocus( inp, function() {
259-
header = dp.children( ":first" );
259+
header = dp.children().first();
260260
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure hide prev/next - header division" );
261261
assert.equal( header.children().length, 1, "Structure hide prev/next - links child count" );
262-
assert.ok( header.children( ":first" ).is( "div.ui-datepicker-title" ), "Structure hide prev/next - title division" );
262+
assert.ok( header.children().first().is( "div.ui-datepicker-title" ), "Structure hide prev/next - title division" );
263263

264264
inp.datepicker( "hide" ).datepicker( "destroy" );
265265
step3();
@@ -271,9 +271,9 @@ QUnit.test( "customStructure", function( assert ) {
271271
inp = testHelper.initNewInput( { changeMonth: true } );
272272

273273
testHelper.onFocus( inp, function() {
274-
title = dp.children( ":first" ).children( ":last" );
274+
title = dp.children().first().children( ":last" );
275275
assert.equal( title.children().length, 2, "Structure changeable month - title child count" );
276-
assert.ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" );
276+
assert.ok( title.children().first().is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" );
277277
assert.ok( title.children( ":last" ).is( "span.ui-datepicker-year" ), "Structure changeable month - read-only year" );
278278

279279
inp.datepicker( "hide" ).datepicker( "destroy" );
@@ -286,9 +286,9 @@ QUnit.test( "customStructure", function( assert ) {
286286
inp = testHelper.initNewInput( { changeYear: true } );
287287

288288
testHelper.onFocus( inp, function() {
289-
title = dp.children( ":first" ).children( ":last" );
289+
title = dp.children().first().children( ":last" );
290290
assert.equal( title.children().length, 2, "Structure changeable year - title child count" );
291-
assert.ok( title.children( ":first" ).is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" );
291+
assert.ok( title.children().first().is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" );
292292
assert.ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure changeable year - year selector" );
293293

294294
inp.datepicker( "hide" ).datepicker( "destroy" );

tests/unit/menu/events.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ QUnit.test( "handle submenu auto collapse: mouseleave, default markup", function
176176

177177
function menumouseleave1() {
178178
assert.equal( element.find( "ul[aria-expanded='true']" ).length, 1, "first submenu expanded" );
179-
element.menu( "focus", event, element.find( "li:nth-child(7) li:first" ) );
179+
element.menu( "focus", event, element.find( "li:nth-child(7) li" ).first() );
180180
setTimeout( menumouseleave2, 25 );
181181
}
182182
function menumouseleave2() {
183183
assert.equal( element.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" );
184-
element.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" );
184+
element.find( "ul[aria-expanded='true']" ).first().trigger( "mouseleave" );
185185
setTimeout( menumouseleave3, 25 );
186186
}
187187
function menumouseleave3() {
@@ -213,7 +213,7 @@ QUnit.test( "handle submenu auto collapse: mouseleave, custom markup", function(
213213
}
214214
function menumouseleave2() {
215215
assert.equal( element.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
216-
element.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
216+
element.find( "div[aria-expanded='true']" ).first().trigger( "mouseleave" );
217217
setTimeout( menumouseleave3, 25 );
218218
}
219219
function menumouseleave3() {

tests/unit/menu/methods.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ QUnit.test( "refresh", function( assert ) {
6262
QUnit.test( "refresh submenu", function( assert ) {
6363
assert.expect( 2 );
6464
var element = $( "#menu2" ).menu();
65-
assert.equal( element.find( "ul:first .ui-menu-item" ).length, 3 );
65+
assert.equal( element.find( "ul" ).first().find( ".ui-menu-item" ).length, 3 );
6666
element.find( "ul" ).addBack().append( "<li><a href=\"#\">New Item</a></li>" );
6767
element.menu( "refresh" );
68-
assert.equal( element.find( "ul:first .ui-menu-item" ).length, 4 );
68+
assert.equal( element.find( "ul" ).first().find( ".ui-menu-item" ).length, 4 );
6969
} );
7070

7171
QUnit.test( "refresh icons (see #9377)", function( assert ) {
7272
assert.expect( 3 );
7373
var element = $( "#menu1" ).menu();
7474
assert.lacksClasses( element, "ui-menu-icons" );
75-
element.find( "li:first .ui-menu-item-wrapper" )
75+
element.find( "li" ).first().find( ".ui-menu-item-wrapper" )
7676
.html( "<span class='ui-icon ui-icon-disk'></span>Save</a>" );
7777
element.menu( "refresh" );
7878

7979
assert.hasClasses( element, "ui-menu-icons" );
80-
element.find( "li:first .ui-menu-item-wrapper" ).html( "Save" );
80+
element.find( "li" ).first().find( ".ui-menu-item-wrapper" ).html( "Save" );
8181
element.menu( "refresh" );
8282
assert.lacksClasses( element, "ui-menu-icons" );
8383
} );

tests/unit/sortable/core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ QUnit.test( "ui-sortable-handle applied to appropriate element", function( asser
2424
.sortable()
2525
.appendTo( "#qunit-fixture" );
2626

27-
assert.hasClasses( el.find( "li:first" ), "ui-sortable-handle" );
28-
assert.hasClasses( el.find( "li:last" ), "ui-sortable-handle" );
27+
assert.hasClasses( el.find( "li" ).first(), "ui-sortable-handle" );
28+
assert.hasClasses( el.find( "li" ).last(), "ui-sortable-handle" );
2929

3030
el.sortable( "option", "handle", "p" );
3131
assert.lacksClasses( el.find( "li" )[ 0 ], "ui-sortable-handle" );

tests/unit/sortable/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ QUnit.test( "{ placholder: String } tbody", function( assert ) {
447447
assert.equal( ui.placeholder.children( "tr" ).length, 1,
448448
"placeholder's child is tr" );
449449
assert.equal( ui.placeholder.find( "> tr" ).children().length,
450-
dragBody.find( "> tr:first" ).children().length,
450+
dragBody.find( "> tr" ).first().children().length,
451451
"placeholder's tr has correct number of cells" );
452452
assert.equal( ui.placeholder.find( "> tr" ).children().html(),
453453
$( "<span>&#160;</span>" ).html(),

tests/unit/spinner/options.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ QUnit.module( "spinner: options" );
1313
QUnit.test( "icons: default ", function( assert ) {
1414
assert.expect( 4 );
1515
var element = $( "#spin" ).val( 0 ).spinner();
16-
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:first" ),
16+
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon" ).first(),
1717
"ui-icon ui-icon-triangle-1-n" );
1818
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:last" ),
1919
"ui-icon ui-icon-triangle-1-s" );
@@ -22,7 +22,7 @@ QUnit.test( "icons: default ", function( assert ) {
2222
up: "ui-icon-caret-1-n",
2323
down: "ui-icon-caret-1-s"
2424
} );
25-
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:first" ),
25+
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon" ).first(),
2626
"ui-icon ui-icon-caret-1-n" );
2727
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:last" ),
2828
"ui-icon ui-icon-caret-1-s" );
@@ -36,7 +36,7 @@ QUnit.test( "icons: custom ", function( assert ) {
3636
up: "custom-up"
3737
}
3838
} ).spinner( "widget" );
39-
assert.hasClasses( element.find( ".ui-icon:first" ), "ui-icon custom-up" );
39+
assert.hasClasses( element.find( ".ui-icon" ).first(), "ui-icon custom-up" );
4040
assert.hasClasses( element.find( ".ui-icon:last" ), "ui-icon custom-down" );
4141
} );
4242

ui/widgets/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ $.extend( Datepicker.prototype, {
858858

859859
//assure that inst.yearshtml didn't change.
860860
if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
861-
inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml );
861+
inst.dpDiv.find( "select.ui-datepicker-year" ).first().replaceWith( inst.yearshtml );
862862
}
863863
origyearshtml = inst.yearshtml = null;
864864
}, 0 );

ui/widgets/dialog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ $.widget( "ui.dialog", {
369369
return;
370370
}
371371
var tabbables = this.uiDialog.find( ":tabbable" ),
372-
first = tabbables.filter( ":first" ),
373-
last = tabbables.filter( ":last" );
372+
first = tabbables.first(),
373+
last = tabbables.last();
374374

375375
if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
376376
!event.shiftKey ) {

0 commit comments

Comments
 (0)