Skip to content

Commit 33fba53

Browse files
committed
All: Rewrite all :last usage to .last()
1 parent af54b60 commit 33fba53

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

tests/unit/datepicker/core.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ QUnit.test( "baseStructure", function( assert ) {
5757
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

60-
title = header.children( ":last" );
60+
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" );
64-
assert.ok( title.children( ":last" ).is( "span.ui-datepicker-year" ) && title.children( ":last" ).text() !== "", "Structure - year text" );
64+
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" );
@@ -77,7 +77,7 @@ QUnit.test( "baseStructure", function( assert ) {
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" );
80-
assert.ok( week.children( ":last" ).is( "td.ui-datepicker-week-end" ), "Structure - month table second day cell" );
80+
assert.ok( week.children().last().is( "td.ui-datepicker-week-end" ), "Structure - month table second day cell" );
8181

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

100-
panel = dp.children( ":last" );
100+
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" );
103103
assert.ok( panel.children().first().is( "button.ui-datepicker-current" ), "Structure - today button" );
104-
assert.ok( panel.children( ":last" ).is( "button.ui-datepicker-close" ), "Structure - close button" );
104+
assert.ok( panel.children().last().is( "button.ui-datepicker-close" ), "Structure - close button" );
105105

106106
inp.datepicker( "hide" ).datepicker( "destroy" );
107107
step3();
@@ -235,11 +235,11 @@ QUnit.test( "customStructure", function( assert ) {
235235
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

238-
panel = dp.children( ":last" );
238+
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" );
241241
assert.ok( panel.children().first().is( "button.ui-datepicker-close" ), "Structure RTL - close button" );
242-
assert.ok( panel.children( ":last" ).is( "button.ui-datepicker-current" ), "Structure RTL - today button" );
242+
assert.ok( panel.children().last().is( "button.ui-datepicker-current" ), "Structure RTL - today button" );
243243

244244
inp.datepicker( "hide" ).datepicker( "destroy" );
245245
step2();
@@ -271,10 +271,10 @@ 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" );
276276
assert.ok( title.children().first().is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" );
277-
assert.ok( title.children( ":last" ).is( "span.ui-datepicker-year" ), "Structure changeable month - read-only year" );
277+
assert.ok( title.children().last().is( "span.ui-datepicker-year" ), "Structure changeable month - read-only year" );
278278

279279
inp.datepicker( "hide" ).datepicker( "destroy" );
280280
step4();
@@ -286,10 +286,10 @@ 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" );
291291
assert.ok( title.children().first().is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" );
292-
assert.ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure changeable year - year selector" );
292+
assert.ok( title.children().last().is( "select.ui-datepicker-year" ), "Structure changeable year - year selector" );
293293

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

tests/unit/datepicker/options.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,23 @@ QUnit.test( "otherMonths", function( assert ) {
247247
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
248248
$( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(),
249249
"Other months - none" );
250-
assert.ok( pop.find( "td:last *" ).length === 0, "Other months - no content" );
250+
assert.ok( pop.find( "td" ).last().find( "*" ).length === 0, "Other months - no content" );
251251
inp.datepicker( "hide" ).datepicker( "option", "showOtherMonths", true ).datepicker( "show" );
252252
assert.equal( pop.find( "tbody" ).text(), "311234567891011121314151617181920212223242526272829301234",
253253
"Other months - show" );
254-
assert.ok( pop.find( "td:last span" ).length === 1, "Other months - span content" );
254+
assert.ok( pop.find( "td" ).last().find( "span" ).length === 1, "Other months - span content" );
255255
inp.datepicker( "hide" ).datepicker( "option", "selectOtherMonths", true ).datepicker( "show" );
256256
assert.equal( pop.find( "tbody" ).text(), "311234567891011121314151617181920212223242526272829301234",
257257
"Other months - select" );
258-
assert.ok( pop.find( "td:last a" ).length === 1, "Other months - link content" );
258+
assert.ok( pop.find( "td" ).last().find( "a" ).length === 1, "Other months - link content" );
259259
inp.datepicker( "hide" ).datepicker( "option", "showOtherMonths", false ).datepicker( "show" );
260260
assert.equal( pop.find( "tbody" ).text(),
261261

262262
// Support: IE <9, jQuery <1.8
263263
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
264264
$( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(),
265265
"Other months - none" );
266-
assert.ok( pop.find( "td:last *" ).length === 0, "Other months - no content" );
266+
assert.ok( pop.find( "td" ).last().find( "*" ).length === 0, "Other months - no content" );
267267
} );
268268

269269
QUnit.test( "defaultDate", function( assert ) {

tests/unit/dialog/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ QUnit.test( "focus tabbable", function( assert ) {
118118

119119
function step1() {
120120
checkFocus( "<div><input><input></div>", options, function( done ) {
121-
var input = element.find( "input:last" ).trigger( "focus" ).trigger( "blur" );
121+
var input = element.find( "input" ).last().trigger( "focus" ).trigger( "blur" );
122122
element.dialog( "instance" )._focusTabbable();
123123
setTimeout( function() {
124124
assert.equal( document.activeElement, input[ 0 ],

tests/unit/menu/events.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ QUnit.test( "handle keyboard navigation on menu without scroll and with submenus
306306
log( $( ui.item[ 0 ] ).text() );
307307
},
308308
focus: function( event ) {
309-
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active:last" ).parent().index() );
309+
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).last().parent().index() );
310310
}
311311
} );
312312

@@ -427,7 +427,7 @@ QUnit.test( "handle keyboard navigation on menu with scroll and without submenus
427427
log( $( ui.item[ 0 ] ).text() );
428428
},
429429
focus: function( event ) {
430-
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active:last" ).parent().index() );
430+
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).last().parent().index() );
431431
}
432432
} );
433433

@@ -503,7 +503,7 @@ QUnit.test( "handle keyboard navigation on menu with scroll and with submenus",
503503
log( $( ui.item[ 0 ] ).text() );
504504
},
505505
focus: function( event ) {
506-
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active:last" ).parent().index() );
506+
log( $( event.target ).find( ".ui-menu-item-wrapper.ui-state-active" ).last().parent().index() );
507507
}
508508
} );
509509

tests/unit/menu/methods.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ QUnit.test( "refresh", function( assert ) {
5151
assert.equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
5252
element.append( "<li><a href='#'>test item</a></li>" ).menu( "refresh" );
5353
assert.equal( element.find( ".ui-menu-item" ).length, 6, "Incorrect number of menu items" );
54-
element.find( ".ui-menu-item:last" ).remove().end().menu( "refresh" );
54+
element.find( ".ui-menu-item" ).last().remove().end().end().menu( "refresh" );
5555
assert.equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
5656
element.append( "<li>---</li>" ).menu( "refresh" );
5757
assert.equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
58-
element.children( ":last" ).remove().end().menu( "refresh" );
58+
element.children().last().remove().end().end().menu( "refresh" );
5959
assert.equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
6060
} );
6161

tests/unit/sortable/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ QUnit.test( "ui-sortable-handle applied to appropriate element", function( asser
3434
assert.hasClasses( el.find( "p" )[ 1 ], "ui-sortable-handle" );
3535

3636
el.append( item ).sortable( "refresh" );
37-
assert.hasClasses( el.find( "p:last" ), "ui-sortable-handle" );
37+
assert.hasClasses( el.find( "p" ).last(), "ui-sortable-handle" );
3838

3939
el.sortable( "destroy" );
4040
assert.equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" );

tests/unit/sortable/events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ QUnit.test( "out, with connected sortable", function( assert ) {
329329
hash = ui;
330330
outCount++;
331331
} );
332-
$( "#sortable" ).find( "li:last" ).simulate( "drag", {
332+
$( "#sortable" ).find( "li" ).last().simulate( "drag", {
333333
dy: 40
334334
} );
335335

@@ -357,7 +357,7 @@ QUnit.test( "repeated out & over between connected sortables", function( assert
357357
}
358358
}
359359
} );
360-
$( "#sortable" ).find( "li:last" ).simulate( "drag", {
360+
$( "#sortable" ).find( "li" ).last().simulate( "drag", {
361361
dy: 40
362362
} ).simulate( "drag", {
363363
dy: -40

tests/unit/spinner/options.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ QUnit.test( "icons: default ", function( assert ) {
1515
var element = $( "#spin" ).val( 0 ).spinner();
1616
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon" ).first(),
1717
"ui-icon ui-icon-triangle-1-n" );
18-
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:last" ),
18+
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon" ).last(),
1919
"ui-icon ui-icon-triangle-1-s" );
2020

2121
element.spinner( "option", "icons", {
@@ -24,7 +24,7 @@ QUnit.test( "icons: default ", function( assert ) {
2424
} );
2525
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon" ).first(),
2626
"ui-icon ui-icon-caret-1-n" );
27-
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:last" ),
27+
assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon" ).last(),
2828
"ui-icon ui-icon-caret-1-s" );
2929
} );
3030

@@ -37,7 +37,7 @@ QUnit.test( "icons: custom ", function( assert ) {
3737
}
3838
} ).spinner( "widget" );
3939
assert.hasClasses( element.find( ".ui-icon" ).first(), "ui-icon custom-up" );
40-
assert.hasClasses( element.find( ".ui-icon:last" ), "ui-icon custom-down" );
40+
assert.hasClasses( element.find( ".ui-icon" ).last(), "ui-icon custom-down" );
4141
} );
4242

4343
QUnit.test( "incremental, false", function( assert ) {

tests/visual/compound/draggable_resizable.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
minHeight: 13,
2828
handles: "s"
2929
});
30-
$( ".draggable:last" ).addClass( "absolute" );
30+
$( ".draggable" ).last().addClass( "absolute" );
3131
</script>
3232
</head>
3333
<body>

0 commit comments

Comments
 (0)