Skip to content
Permalink
Browse files

.attr() -> .prop()

  • Loading branch information
scottgonzalez committed Jun 8, 2011
1 parent 7cd3d0a commit da84672db8ad1f3909e645a665e9a9c6c0de0ded
@@ -39,15 +39,15 @@ test( "accessibility", function () {
equals( element.attr( "role" ), "tablist", "main role" );
equals( headers.attr( "role" ), "tab", "tab roles" );
equals( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
equals( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
equals( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
equals( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
equals( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
equals( headers.eq( 1 ).prop( "aria-expanded" ), true, "active tab has aria-expanded" );
equals( headers.eq( 0 ).prop( "aria-expanded" ), false, "inactive tab has aria-expanded" );
equals( headers.eq( 1 ).prop( "aria-selected" ), true, "active tab has aria-selected" );
equals( headers.eq( 0 ).prop( "aria-selected" ), false, "inactive tab has aria-selected" );
element.accordion( "option", "active", 0 );
equals( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
equals( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
equals( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
equals( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
equals( headers.eq( 0 ).prop( "aria-expanded" ), true, "newly active tab has aria-expanded" );
equals( headers.eq( 1 ).prop( "aria-expanded" ), false, "newly inactive tab has aria-expanded" );
equals( headers.eq( 0 ).prop( "aria-selected" ), true, "active tab has aria-selected" );
equals( headers.eq( 1 ).prop( "aria-selected" ), false, "inactive tab has aria-selected" );
});

}( jQuery ) );
@@ -5,28 +5,28 @@

module("button: options");

test("disabled, explicity value", function() {
test("disabled, explicit value", function() {
$("#radio01").button({ disabled: false });
same(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
same(false, $("#radio01").attr("disabled"), "element is disabled");
same(false, $("#radio01").prop("disabled"), "element is disabled");

$("#radio02").button({ disabled: true });
same(true, $("#radio02").button("option", "disabled"),
"disabled option set to true");
same(true, $("#radio02").attr("disabled"), "element is not disabled");
same(true, $("#radio02").prop("disabled"), "element is not disabled");
});

test("disabled, null", function() {
$("#radio01").button({ disabled: null });
same(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
same(false, $("#radio01").attr("disabled"), "element is disabled");
same(false, $("#radio01").prop("disabled"), "element is disabled");

$("#radio02").attr("disabled", "disabled").button({ disabled: null });
$("#radio02").prop("disabled", true).button({ disabled: null });
same(true, $("#radio02").button("option", "disabled"),
"disabled option set to true");
same(true, $("#radio02").attr("disabled"), "element is not disabled");
same(true, $("#radio02").prop("disabled"), "element is not disabled");
});

test("text false without icon", function() {
@@ -108,14 +108,6 @@ <h2 id="qunit-userAgent"></h2>
<span id="spanTabindex-50" tabindex="-50">.</span>
</div>

<div>
<input id="inputTabindexfoo" tabindex="foo" />
<input id="inputTabindex3foo" tabindex="3foo" />

<span id="spanTabindexfoo" tabindex="foo">.</span>
<span id="spanTabindex3foo" tabindex="3foo">.</span>
</div>

<div id="zIndex100" style="z-index: 100; position: absolute">
<div id="zIndexAutoWithParent">.</div>
</div>
@@ -147,15 +147,6 @@ test("focusable - not natively focusable with various tabindex", function() {
isFocusable('#spanTabindex-50', 'span, tabindex -50');
});

test("focusable - invalid tabindex", function() {
expect(4);

isFocusable('#inputTabindexfoo', 'input, tabindex foo');
isFocusable('#inputTabindex3foo', 'input, tabindex 3foo');
isNotFocusable('#spanTabindexfoo', 'span tabindex foo');
isNotFocusable('#spanTabindex3foo', 'span, tabindex 3foo');
});

test("focusable - area elements", function() {
isNotFocusable('#areaCoordsNoHref', 'coords but no href');
isFocusable('#areaCoordsHref', 'coords and href');
@@ -233,15 +224,6 @@ test("tabbable - not natively tabbable with various tabindex", function() {
isNotTabbable('#spanTabindex-50', 'span, tabindex -50');
});

test("tabbable - invalid tabindex", function() {
expect(4);

isTabbable('#inputTabindexfoo', 'input, tabindex foo');
isTabbable('#inputTabindex3foo', 'input, tabindex 3foo');
isNotTabbable('#spanTabindexfoo', 'span tabindex foo');
isNotTabbable('#spanTabindex3foo', 'span, tabindex 3foo');
});

test("tabbable - area elements", function() {
isNotTabbable('#areaCoordsNoHref', 'coords but no href');
isTabbable('#areaCoordsHref', 'coords and href');
@@ -106,15 +106,15 @@ test('enableDisable', function() {
var dp = $('.ui-datepicker-inline', inl);
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled');
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially');
ok(!dp.find('select').attr('disabled'), 'Enable/disable inline - form element enabled initially');
ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled initially');
inl.datepicker('disable');
ok(inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as disabled');
ok(dp.children().is('.ui-state-disabled'), 'Enable/disable inline - visually disabled');
ok(dp.find('select').attr('disabled'), 'Enable/disable inline - form element disabled');
ok(dp.find('select').prop('disabled'), 'Enable/disable inline - form element disabled');
inl.datepicker('enable');
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as enabled');
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visiually disabled');
ok(!dp.find('select').attr('disabled'), 'Enable/disable inline - form element enabled');
ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled');
inl.datepicker('destroy');
});

@@ -531,40 +531,37 @@ test('altField', function() {

test('autoSize', function() {
var inp = init('#inp');
equals(inp.attr('size'), 20, 'Auto size - default');
equals(inp.prop('size'), 20, 'Auto size - default');
inp.datepicker('option', 'autoSize', true);
equals(inp.attr('size'), 10, 'Auto size - mm/dd/yy');
equals(inp.prop('size'), 10, 'Auto size - mm/dd/yy');
inp.datepicker('option', 'dateFormat', 'm/d/yy');
equals(inp.attr('size'), 10, 'Auto size - m/d/yy');
equals(inp.prop('size'), 10, 'Auto size - m/d/yy');
inp.datepicker('option', 'dateFormat', 'D M d yy');
equals(inp.attr('size'), 15, 'Auto size - D M d yy');
equals(inp.prop('size'), 15, 'Auto size - D M d yy');
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
equals(inp.attr('size'), 29, 'Auto size - DD, MM dd, yy');
inp.removeAttr('size');
equals(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy');
// French
inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['fr']));
equals(inp.attr('size'), 20, 'Auto size - fr - default');
equals(inp.prop('size'), 29, 'Auto size - fr - default');
inp.datepicker('option', 'autoSize', true);
equals(inp.attr('size'), 10, 'Auto size - fr - dd/mm/yy');
equals(inp.prop('size'), 10, 'Auto size - fr - dd/mm/yy');
inp.datepicker('option', 'dateFormat', 'm/d/yy');
equals(inp.attr('size'), 10, 'Auto size - fr - m/d/yy');
equals(inp.prop('size'), 10, 'Auto size - fr - m/d/yy');
inp.datepicker('option', 'dateFormat', 'D M d yy');
equals(inp.attr('size'), 18, 'Auto size - fr - D M d yy');
equals(inp.prop('size'), 18, 'Auto size - fr - D M d yy');
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
equals(inp.attr('size'), 28, 'Auto size - fr - DD, MM dd, yy');
inp.removeAttr('size');
equals(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy');
// Hebrew
inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['he']));
equals(inp.attr('size'), 20, 'Auto size - he - default');
equals(inp.prop('size'), 28, 'Auto size - he - default');
inp.datepicker('option', 'autoSize', true);
equals(inp.attr('size'), 10, 'Auto size - he - dd/mm/yy');
equals(inp.prop('size'), 10, 'Auto size - he - dd/mm/yy');
inp.datepicker('option', 'dateFormat', 'm/d/yy');
equals(inp.attr('size'), 10, 'Auto size - he - m/d/yy');
equals(inp.prop('size'), 10, 'Auto size - he - m/d/yy');
inp.datepicker('option', 'dateFormat', 'D M d yy');
equals(inp.attr('size'), 14, 'Auto size - he - D M d yy');
equals(inp.prop('size'), 14, 'Auto size - he - D M d yy');
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
equals(inp.attr('size'), 23, 'Auto size - he - DD, MM dd, yy');
inp.removeAttr('size');
equals(inp.prop('size'), 23, 'Auto size - he - DD, MM dd, yy');
});

test('daylightSaving', function() {
@@ -702,7 +699,7 @@ test('callbacks', function() {
ok(day21.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 21');
ok(day20.is('.day10'), 'Before show day - CSS 20');
ok(!day21.is('.day10'), 'Before show day - CSS 21');
ok(day20.attr('title') == '', 'Before show day - title 20');
ok(!day20.attr('title'), 'Before show day - title 20');
ok(day21.attr('title') == 'Divisble by 3', 'Before show day - title 21');
inp.datepicker('hide').datepicker('destroy');
});
@@ -65,17 +65,15 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() {
expect(2);

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

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

d2 = $('<div></div>').dialog({autoOpen: false});

d1.dialog('open');
equal($('input:checked').val(), 'b', "checkbox b is checked");

d1.add(d2).remove();
d1.remove();
});

test("#6645: Missing element not found check in overlay", function(){
@@ -19,10 +19,10 @@ test("accessibility", function() {
el.progressbar("value", 77);
equals(el.attr("aria-valuenow"), 77, "aria-valuenow");
el.progressbar("disable");
equals(el.attr("aria-disabled"), "true", "aria-disabled on");
equals(el.prop("aria-disabled"), true, "aria-disabled on");
el.progressbar("enable");
// FAIL: for some reason IE6 and 7 return a boolean false instead of the string
equals(el.attr("aria-disabled"), $.browser.msie && $.browser.version == 6 || $.browser.version == 7 ? false : "false", "aria-disabled off");
equals(el.prop("aria-disabled"), false, "aria-disabled off");
});

})(jQuery);
@@ -82,7 +82,7 @@ window.domEqual = function( selector, modifier, message ) {
var result = {};
result.nodeName = value[0].nodeName;
$.each(attributes, function(index, attr) {
result[attr] = value.attr(attr);
result[attr] = value.prop(attr);
});
result.children = [];
var children = value.children();
@@ -40,7 +40,7 @@ test( "enable/disable", function() {

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

element.tooltip( "open" );
equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" );
@@ -78,11 +78,11 @@ $.widget( "ui.accordion", {

self.headers
.not( self.active )
.attr({
"aria-expanded": "false",
"aria-selected": "false",
tabIndex: -1
.prop({
"aria-expanded": false,
"aria-selected": false
})
.attr( "tabIndex", -1 )
.next()
.hide();

@@ -91,11 +91,11 @@ $.widget( "ui.accordion", {
self.headers.eq( 0 ).attr( "tabIndex", 0 );
} else {
self.active
.attr({
"aria-expanded": "true",
"aria-selected": "true",
tabIndex: 0
});
.prop({
"aria-expanded": true,
"aria-selected": true
})
.attr( "tabIndex", 0 );
}

// only need links in tab order for Safari
@@ -135,8 +135,8 @@ $.widget( "ui.accordion", {
.unbind( ".accordion" )
.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" )
.removeAttr( "role" )
.removeAttr( "aria-expanded" )
.removeAttr( "aria-selected" )
.removeProp( "aria-expanded" )
.removeProp( "aria-selected" )
.removeAttr( "tabIndex" )
.find( "a" )
.removeAttr( "tabIndex" )
@@ -393,18 +393,18 @@ $.widget( "ui.accordion", {

// TODO assert that the blur and focus triggers are really necessary, remove otherwise
toHide.prev()
.attr({
"aria-expanded": "false",
"aria-selected": "false",
tabIndex: -1
.prop({
"aria-expanded": false,
"aria-selected": false
})
.attr( "tabIndex", -1 )
.blur();
toShow.prev()
.attr({
"aria-expanded": "true",
"aria-selected": "true",
tabIndex: 0
.prop({
"aria-expanded": true,
"aria-selected": true
})
.attr( "tabIndex", 0 )
.focus();
},

@@ -59,11 +59,11 @@ $.widget( "ui.autocomplete", {
// TODO verify these actually work as intended
.attr({
role: "textbox",
"aria-autocomplete": "list",
"aria-haspopup": "true"
"aria-autocomplete": "list"
})
.prop( "aria-haspopup", true )
.bind( "keydown.autocomplete", function( event ) {
if ( self.options.disabled || self.element.attr( "readonly" ) ) {
if ( self.options.disabled || self.element.prop( "readonly" ) ) {
suppressKeyPress = true;
suppressInput = true;
return;
@@ -268,7 +268,7 @@ $.widget( "ui.autocomplete", {
.removeAttr( "autocomplete" )
.removeAttr( "role" )
.removeAttr( "aria-autocomplete" )
.removeAttr( "aria-haspopup" );
.removeProp( "aria-haspopup" );
this.menu.element.remove();
},

0 comments on commit da84672

Please sign in to comment.
You can’t perform that action at this time.