Skip to content

Commit da84672

Browse files
committed
.attr() -> .prop()
1 parent 7cd3d0a commit da84672

21 files changed

+130
-155
lines changed

tests/unit/accordion/accordion_core.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ test( "accessibility", function () {
3939
equals( element.attr( "role" ), "tablist", "main role" );
4040
equals( headers.attr( "role" ), "tab", "tab roles" );
4141
equals( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
42-
equals( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
43-
equals( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
44-
equals( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
45-
equals( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
42+
equals( headers.eq( 1 ).prop( "aria-expanded" ), true, "active tab has aria-expanded" );
43+
equals( headers.eq( 0 ).prop( "aria-expanded" ), false, "inactive tab has aria-expanded" );
44+
equals( headers.eq( 1 ).prop( "aria-selected" ), true, "active tab has aria-selected" );
45+
equals( headers.eq( 0 ).prop( "aria-selected" ), false, "inactive tab has aria-selected" );
4646
element.accordion( "option", "active", 0 );
47-
equals( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
48-
equals( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
49-
equals( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
50-
equals( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
47+
equals( headers.eq( 0 ).prop( "aria-expanded" ), true, "newly active tab has aria-expanded" );
48+
equals( headers.eq( 1 ).prop( "aria-expanded" ), false, "newly inactive tab has aria-expanded" );
49+
equals( headers.eq( 0 ).prop( "aria-selected" ), true, "active tab has aria-selected" );
50+
equals( headers.eq( 1 ).prop( "aria-selected" ), false, "inactive tab has aria-selected" );
5151
});
5252

5353
}( jQuery ) );

tests/unit/button/button_options.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55

66
module("button: options");
77

8-
test("disabled, explicity value", function() {
8+
test("disabled, explicit value", function() {
99
$("#radio01").button({ disabled: false });
1010
same(false, $("#radio01").button("option", "disabled"),
1111
"disabled option set to false");
12-
same(false, $("#radio01").attr("disabled"), "element is disabled");
12+
same(false, $("#radio01").prop("disabled"), "element is disabled");
1313

1414
$("#radio02").button({ disabled: true });
1515
same(true, $("#radio02").button("option", "disabled"),
1616
"disabled option set to true");
17-
same(true, $("#radio02").attr("disabled"), "element is not disabled");
17+
same(true, $("#radio02").prop("disabled"), "element is not disabled");
1818
});
1919

2020
test("disabled, null", function() {
2121
$("#radio01").button({ disabled: null });
2222
same(false, $("#radio01").button("option", "disabled"),
2323
"disabled option set to false");
24-
same(false, $("#radio01").attr("disabled"), "element is disabled");
24+
same(false, $("#radio01").prop("disabled"), "element is disabled");
2525

26-
$("#radio02").attr("disabled", "disabled").button({ disabled: null });
26+
$("#radio02").prop("disabled", true).button({ disabled: null });
2727
same(true, $("#radio02").button("option", "disabled"),
2828
"disabled option set to true");
29-
same(true, $("#radio02").attr("disabled"), "element is not disabled");
29+
same(true, $("#radio02").prop("disabled"), "element is not disabled");
3030
});
3131

3232
test("text false without icon", function() {

tests/unit/core/core.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,6 @@ <h2 id="qunit-userAgent"></h2>
108108
<span id="spanTabindex-50" tabindex="-50">.</span>
109109
</div>
110110

111-
<div>
112-
<input id="inputTabindexfoo" tabindex="foo" />
113-
<input id="inputTabindex3foo" tabindex="3foo" />
114-
115-
<span id="spanTabindexfoo" tabindex="foo">.</span>
116-
<span id="spanTabindex3foo" tabindex="3foo">.</span>
117-
</div>
118-
119111
<div id="zIndex100" style="z-index: 100; position: absolute">
120112
<div id="zIndexAutoWithParent">.</div>
121113
</div>

tests/unit/core/selector.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,6 @@ test("focusable - not natively focusable with various tabindex", function() {
147147
isFocusable('#spanTabindex-50', 'span, tabindex -50');
148148
});
149149

150-
test("focusable - invalid tabindex", function() {
151-
expect(4);
152-
153-
isFocusable('#inputTabindexfoo', 'input, tabindex foo');
154-
isFocusable('#inputTabindex3foo', 'input, tabindex 3foo');
155-
isNotFocusable('#spanTabindexfoo', 'span tabindex foo');
156-
isNotFocusable('#spanTabindex3foo', 'span, tabindex 3foo');
157-
});
158-
159150
test("focusable - area elements", function() {
160151
isNotFocusable('#areaCoordsNoHref', 'coords but no href');
161152
isFocusable('#areaCoordsHref', 'coords and href');
@@ -233,15 +224,6 @@ test("tabbable - not natively tabbable with various tabindex", function() {
233224
isNotTabbable('#spanTabindex-50', 'span, tabindex -50');
234225
});
235226

236-
test("tabbable - invalid tabindex", function() {
237-
expect(4);
238-
239-
isTabbable('#inputTabindexfoo', 'input, tabindex foo');
240-
isTabbable('#inputTabindex3foo', 'input, tabindex 3foo');
241-
isNotTabbable('#spanTabindexfoo', 'span tabindex foo');
242-
isNotTabbable('#spanTabindex3foo', 'span, tabindex 3foo');
243-
});
244-
245227
test("tabbable - area elements", function() {
246228
isNotTabbable('#areaCoordsNoHref', 'coords but no href');
247229
isTabbable('#areaCoordsHref', 'coords and href');

tests/unit/datepicker/datepicker_methods.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ test('enableDisable', function() {
106106
var dp = $('.ui-datepicker-inline', inl);
107107
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled');
108108
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially');
109-
ok(!dp.find('select').attr('disabled'), 'Enable/disable inline - form element enabled initially');
109+
ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled initially');
110110
inl.datepicker('disable');
111111
ok(inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as disabled');
112112
ok(dp.children().is('.ui-state-disabled'), 'Enable/disable inline - visually disabled');
113-
ok(dp.find('select').attr('disabled'), 'Enable/disable inline - form element disabled');
113+
ok(dp.find('select').prop('disabled'), 'Enable/disable inline - form element disabled');
114114
inl.datepicker('enable');
115115
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as enabled');
116116
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visiually disabled');
117-
ok(!dp.find('select').attr('disabled'), 'Enable/disable inline - form element enabled');
117+
ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled');
118118
inl.datepicker('destroy');
119119
});
120120

tests/unit/datepicker/datepicker_options.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -531,40 +531,37 @@ test('altField', function() {
531531

532532
test('autoSize', function() {
533533
var inp = init('#inp');
534-
equals(inp.attr('size'), 20, 'Auto size - default');
534+
equals(inp.prop('size'), 20, 'Auto size - default');
535535
inp.datepicker('option', 'autoSize', true);
536-
equals(inp.attr('size'), 10, 'Auto size - mm/dd/yy');
536+
equals(inp.prop('size'), 10, 'Auto size - mm/dd/yy');
537537
inp.datepicker('option', 'dateFormat', 'm/d/yy');
538-
equals(inp.attr('size'), 10, 'Auto size - m/d/yy');
538+
equals(inp.prop('size'), 10, 'Auto size - m/d/yy');
539539
inp.datepicker('option', 'dateFormat', 'D M d yy');
540-
equals(inp.attr('size'), 15, 'Auto size - D M d yy');
540+
equals(inp.prop('size'), 15, 'Auto size - D M d yy');
541541
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
542-
equals(inp.attr('size'), 29, 'Auto size - DD, MM dd, yy');
543-
inp.removeAttr('size');
542+
equals(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy');
544543
// French
545544
inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['fr']));
546-
equals(inp.attr('size'), 20, 'Auto size - fr - default');
545+
equals(inp.prop('size'), 29, 'Auto size - fr - default');
547546
inp.datepicker('option', 'autoSize', true);
548-
equals(inp.attr('size'), 10, 'Auto size - fr - dd/mm/yy');
547+
equals(inp.prop('size'), 10, 'Auto size - fr - dd/mm/yy');
549548
inp.datepicker('option', 'dateFormat', 'm/d/yy');
550-
equals(inp.attr('size'), 10, 'Auto size - fr - m/d/yy');
549+
equals(inp.prop('size'), 10, 'Auto size - fr - m/d/yy');
551550
inp.datepicker('option', 'dateFormat', 'D M d yy');
552-
equals(inp.attr('size'), 18, 'Auto size - fr - D M d yy');
551+
equals(inp.prop('size'), 18, 'Auto size - fr - D M d yy');
553552
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
554-
equals(inp.attr('size'), 28, 'Auto size - fr - DD, MM dd, yy');
555-
inp.removeAttr('size');
553+
equals(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy');
556554
// Hebrew
557555
inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['he']));
558-
equals(inp.attr('size'), 20, 'Auto size - he - default');
556+
equals(inp.prop('size'), 28, 'Auto size - he - default');
559557
inp.datepicker('option', 'autoSize', true);
560-
equals(inp.attr('size'), 10, 'Auto size - he - dd/mm/yy');
558+
equals(inp.prop('size'), 10, 'Auto size - he - dd/mm/yy');
561559
inp.datepicker('option', 'dateFormat', 'm/d/yy');
562-
equals(inp.attr('size'), 10, 'Auto size - he - m/d/yy');
560+
equals(inp.prop('size'), 10, 'Auto size - he - m/d/yy');
563561
inp.datepicker('option', 'dateFormat', 'D M d yy');
564-
equals(inp.attr('size'), 14, 'Auto size - he - D M d yy');
562+
equals(inp.prop('size'), 14, 'Auto size - he - D M d yy');
565563
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
566-
equals(inp.attr('size'), 23, 'Auto size - he - DD, MM dd, yy');
567-
inp.removeAttr('size');
564+
equals(inp.prop('size'), 23, 'Auto size - he - DD, MM dd, yy');
568565
});
569566

570567
test('daylightSaving', function() {
@@ -702,7 +699,7 @@ test('callbacks', function() {
702699
ok(day21.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 21');
703700
ok(day20.is('.day10'), 'Before show day - CSS 20');
704701
ok(!day21.is('.day10'), 'Before show day - CSS 21');
705-
ok(day20.attr('title') == '', 'Before show day - title 20');
702+
ok(!day20.attr('title'), 'Before show day - title 20');
706703
ok(day21.attr('title') == 'Divisble by 3', 'Before show day - title 21');
707704
inp.datepicker('hide').datepicker('destroy');
708705
});

tests/unit/dialog/dialog_tickets.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,15 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() {
6565
expect(2);
6666

6767
d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' +
68-
'<input type="radio" name="radio" id="b" value="b">b</input></form>').dialog({autoOpen: false});
68+
'<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false});
6969

70-
d1.find('#b')[0].checked = true;
70+
d1.find('#b').prop( "checked", true );
7171
equal($('input:checked').val(), 'b', "checkbox b is checked");
7272

73-
d2 = $('<div></div>').dialog({autoOpen: false});
74-
7573
d1.dialog('open');
7674
equal($('input:checked').val(), 'b', "checkbox b is checked");
7775

78-
d1.add(d2).remove();
76+
d1.remove();
7977
});
8078

8179
test("#6645: Missing element not found check in overlay", function(){

tests/unit/progressbar/progressbar_core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ test("accessibility", function() {
1919
el.progressbar("value", 77);
2020
equals(el.attr("aria-valuenow"), 77, "aria-valuenow");
2121
el.progressbar("disable");
22-
equals(el.attr("aria-disabled"), "true", "aria-disabled on");
22+
equals(el.prop("aria-disabled"), true, "aria-disabled on");
2323
el.progressbar("enable");
2424
// FAIL: for some reason IE6 and 7 return a boolean false instead of the string
25-
equals(el.attr("aria-disabled"), $.browser.msie && $.browser.version == 6 || $.browser.version == 7 ? false : "false", "aria-disabled off");
25+
equals(el.prop("aria-disabled"), false, "aria-disabled off");
2626
});
2727

2828
})(jQuery);

tests/unit/testsuite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ window.domEqual = function( selector, modifier, message ) {
8282
var result = {};
8383
result.nodeName = value[0].nodeName;
8484
$.each(attributes, function(index, attr) {
85-
result[attr] = value.attr(attr);
85+
result[attr] = value.prop(attr);
8686
});
8787
result.children = [];
8888
var children = value.children();

tests/unit/tooltip/tooltip_methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test( "enable/disable", function() {
4040

4141
element.tooltip( "disable" );
4242
equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" );
43-
equal( tooltip.attr( "title" ), "", "title removed on disable" );
43+
equal( tooltip.attr( "title" ), undefined, "title removed on disable" );
4444

4545
element.tooltip( "open" );
4646
equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" );

ui/jquery.ui.accordion.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ $.widget( "ui.accordion", {
7878

7979
self.headers
8080
.not( self.active )
81-
.attr({
82-
"aria-expanded": "false",
83-
"aria-selected": "false",
84-
tabIndex: -1
81+
.prop({
82+
"aria-expanded": false,
83+
"aria-selected": false
8584
})
85+
.attr( "tabIndex", -1 )
8686
.next()
8787
.hide();
8888

@@ -91,11 +91,11 @@ $.widget( "ui.accordion", {
9191
self.headers.eq( 0 ).attr( "tabIndex", 0 );
9292
} else {
9393
self.active
94-
.attr({
95-
"aria-expanded": "true",
96-
"aria-selected": "true",
97-
tabIndex: 0
98-
});
94+
.prop({
95+
"aria-expanded": true,
96+
"aria-selected": true
97+
})
98+
.attr( "tabIndex", 0 );
9999
}
100100

101101
// only need links in tab order for Safari
@@ -135,8 +135,8 @@ $.widget( "ui.accordion", {
135135
.unbind( ".accordion" )
136136
.removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
137137
.removeAttr( "role" )
138-
.removeAttr( "aria-expanded" )
139-
.removeAttr( "aria-selected" )
138+
.removeProp( "aria-expanded" )
139+
.removeProp( "aria-selected" )
140140
.removeAttr( "tabIndex" )
141141
.find( "a" )
142142
.removeAttr( "tabIndex" )
@@ -393,18 +393,18 @@ $.widget( "ui.accordion", {
393393

394394
// TODO assert that the blur and focus triggers are really necessary, remove otherwise
395395
toHide.prev()
396-
.attr({
397-
"aria-expanded": "false",
398-
"aria-selected": "false",
399-
tabIndex: -1
396+
.prop({
397+
"aria-expanded": false,
398+
"aria-selected": false
400399
})
400+
.attr( "tabIndex", -1 )
401401
.blur();
402402
toShow.prev()
403-
.attr({
404-
"aria-expanded": "true",
405-
"aria-selected": "true",
406-
tabIndex: 0
403+
.prop({
404+
"aria-expanded": true,
405+
"aria-selected": true
407406
})
407+
.attr( "tabIndex", 0 )
408408
.focus();
409409
},
410410

ui/jquery.ui.autocomplete.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ $.widget( "ui.autocomplete", {
5959
// TODO verify these actually work as intended
6060
.attr({
6161
role: "textbox",
62-
"aria-autocomplete": "list",
63-
"aria-haspopup": "true"
62+
"aria-autocomplete": "list"
6463
})
64+
.prop( "aria-haspopup", true )
6565
.bind( "keydown.autocomplete", function( event ) {
66-
if ( self.options.disabled || self.element.attr( "readonly" ) ) {
66+
if ( self.options.disabled || self.element.prop( "readonly" ) ) {
6767
suppressKeyPress = true;
6868
suppressInput = true;
6969
return;
@@ -268,7 +268,7 @@ $.widget( "ui.autocomplete", {
268268
.removeAttr( "autocomplete" )
269269
.removeAttr( "role" )
270270
.removeAttr( "aria-autocomplete" )
271-
.removeAttr( "aria-haspopup" );
271+
.removeProp( "aria-haspopup" );
272272
this.menu.element.remove();
273273
},
274274

0 commit comments

Comments
 (0)