Skip to content

Commit 0080f2d

Browse files
committed
Use .attr() for boolean ARIA attributes.
1 parent da84672 commit 0080f2d

File tree

9 files changed

+77
-78
lines changed

9 files changed

+77
-78
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 ).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" );
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" );
4646
element.accordion( "option", "active", 0 );
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" );
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" );
5151
});
5252

5353
}( jQuery ) );

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.prop("aria-disabled"), true, "aria-disabled on");
22+
equals(el.attr("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.prop("aria-disabled"), false, "aria-disabled off");
25+
equals(el.attr("aria-disabled"), "false", "aria-disabled off");
2626
});
2727

2828
})(jQuery);

ui/jquery.ui.accordion.js

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

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

8989
// make sure at least one header is in the tab order
9090
if ( !self.active.length ) {
9191
self.headers.eq( 0 ).attr( "tabIndex", 0 );
9292
} else {
93-
self.active
94-
.prop({
95-
"aria-expanded": true,
96-
"aria-selected": true
97-
})
98-
.attr( "tabIndex", 0 );
93+
self.active.attr({
94+
"aria-expanded": "true",
95+
"aria-selected": "true",
96+
tabIndex: 0
97+
});
9998
}
10099

101100
// only need links in tab order for Safari
@@ -135,8 +134,8 @@ $.widget( "ui.accordion", {
135134
.unbind( ".accordion" )
136135
.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" )
137136
.removeAttr( "role" )
138-
.removeProp( "aria-expanded" )
139-
.removeProp( "aria-selected" )
137+
.removeAttr( "aria-expanded" )
138+
.removeAttr( "aria-selected" )
140139
.removeAttr( "tabIndex" )
141140
.find( "a" )
142141
.removeAttr( "tabIndex" )
@@ -393,18 +392,18 @@ $.widget( "ui.accordion", {
393392

394393
// TODO assert that the blur and focus triggers are really necessary, remove otherwise
395394
toHide.prev()
396-
.prop({
397-
"aria-expanded": false,
398-
"aria-selected": false
395+
.attr({
396+
"aria-expanded": "false",
397+
"aria-selected": "false",
398+
tabIndex: -1
399399
})
400-
.attr( "tabIndex", -1 )
401400
.blur();
402401
toShow.prev()
403-
.prop({
404-
"aria-expanded": true,
405-
"aria-selected": true
402+
.attr({
403+
"aria-expanded": "true",
404+
"aria-selected": "true",
405+
tabIndex: 0
406406
})
407-
.attr( "tabIndex", 0 )
408407
.focus();
409408
},
410409

ui/jquery.ui.autocomplete.js

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

ui/jquery.ui.button.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ $.widget( "ui.button", {
147147
return false;
148148
}
149149
$( this ).toggleClass( "ui-state-active" );
150-
self.buttonElement.prop( "aria-pressed", self.element[0].checked );
150+
self.buttonElement.attr( "aria-pressed", self.element[0].checked );
151151
});
152152
} else if ( this.type === "radio" ) {
153153
this.buttonElement.bind( "click.button", function() {
154154
if ( options.disabled || clickDragged ) {
155155
return false;
156156
}
157157
$( this ).addClass( "ui-state-active" );
158-
self.buttonElement.prop( "aria-pressed", true );
158+
self.buttonElement.attr( "aria-pressed", "true" );
159159

160160
var radio = self.element[ 0 ];
161161
radioGroup( radio )
@@ -164,7 +164,7 @@ $.widget( "ui.button", {
164164
return $( this ).button( "widget" )[ 0 ];
165165
})
166166
.removeClass( "ui-state-active" )
167-
.prop( "aria-pressed", false );
167+
.attr( "aria-pressed", "false" );
168168
});
169169
} else {
170170
this.buttonElement
@@ -260,7 +260,7 @@ $.widget( "ui.button", {
260260
this.buttonElement
261261
.removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
262262
.removeAttr( "role" )
263-
.removeProp( "aria-pressed" )
263+
.removeAttr( "aria-pressed" )
264264
.html( this.buttonElement.find(".ui-button-text").html() );
265265

266266
if ( !this.hasTitle ) {
@@ -291,22 +291,22 @@ $.widget( "ui.button", {
291291
if ( $( this ).is( ":checked" ) ) {
292292
$( this ).button( "widget" )
293293
.addClass( "ui-state-active" )
294-
.prop( "aria-pressed", true );
294+
.attr( "aria-pressed", "true" );
295295
} else {
296296
$( this ).button( "widget" )
297297
.removeClass( "ui-state-active" )
298-
.prop( "aria-pressed", false );
298+
.attr( "aria-pressed", "false" );
299299
}
300300
});
301301
} else if ( this.type === "checkbox" ) {
302302
if ( this.element.is( ":checked" ) ) {
303303
this.buttonElement
304304
.addClass( "ui-state-active" )
305-
.prop( "aria-pressed", true );
305+
.attr( "aria-pressed", "true" );
306306
} else {
307307
this.buttonElement
308308
.removeClass( "ui-state-active" )
309-
.prop( "aria-pressed", false );
309+
.attr( "aria-pressed", "false" );
310310
}
311311
}
312312
},

ui/jquery.ui.menu.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ $.widget("ui.menu", {
178178
.removeAttr( "role" )
179179
.removeAttr("tabIndex")
180180
.removeAttr( "aria-labelledby" )
181-
.removeProp( "aria-expanded" )
182-
.removeProp( "aria-hidden" )
181+
.removeAttr( "aria-expanded" )
182+
.removeAttr( "aria-hidden" )
183183
.show();
184184

185185
//destroy menu items
@@ -191,7 +191,7 @@ $.widget("ui.menu", {
191191
.removeClass( "ui-corner-all ui-state-hover" )
192192
.removeAttr( "tabIndex" )
193193
.removeAttr( "role" )
194-
.removeProp( "aria-haspopup" )
194+
.removeAttr( "aria-haspopup" )
195195
.removeAttr( "id" )
196196
.children(".ui-icon").remove();
197197
},
@@ -203,9 +203,9 @@ $.widget("ui.menu", {
203203
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
204204
.attr("role", "menu")
205205
.hide()
206-
.prop({
207-
"aria-hidden": true,
208-
"aria-expanded": false
206+
.attr({
207+
"aria-hidden": "true",
208+
"aria-expanded": "false"
209209
});
210210

211211
// don't refresh list items that are already adapted
@@ -222,7 +222,7 @@ $.widget("ui.menu", {
222222
submenus.each(function() {
223223
var menu = $(this);
224224
var item = menu.prev("a")
225-
item.prop("aria-haspopup", true)
225+
item.attr("aria-haspopup", "true")
226226
.prepend('<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>');
227227
menu.attr("aria-labelledby", item.attr("id"));
228228
});
@@ -290,34 +290,34 @@ $.widget("ui.menu", {
290290

291291
_open: function(submenu) {
292292
clearTimeout(this.timer);
293-
this.element.find(".ui-menu").not(submenu.parents()).hide().prop("aria-hidden", true);
293+
this.element.find(".ui-menu").not(submenu.parents()).hide().attr("aria-hidden", "true");
294294
var position = $.extend({}, {
295295
of: this.active
296296
}, $.type(this.options.position) == "function"
297297
? this.options.position(this.active)
298298
: this.options.position
299299
);
300-
submenu.show().removeProp("aria-hidden").prop("aria-expanded", true).position(position);
300+
submenu.show().removeAttr("aria-hidden").attr("aria-expanded", "true").position(position);
301301
},
302302

303303
closeAll: function() {
304304
this.element
305-
.find("ul").hide().prop("aria-hidden", true).prop("aria-expanded", false).end()
305+
.find("ul").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end()
306306
.find("a.ui-state-active").removeClass("ui-state-active");
307307
this.blur();
308308
this.activeMenu = this.element;
309309
},
310310

311311
_close: function() {
312312
this.active.parent()
313-
.find("ul").hide().prop("aria-hidden", true).prop("aria-expanded", false).end()
313+
.find("ul").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end()
314314
.find("a.ui-state-active").removeClass("ui-state-active");
315315
},
316316

317317
left: function(event) {
318318
var newItem = this.active && this.active.parents("li:not(.ui-menubar-item)").first();
319319
if (newItem && newItem.length) {
320-
this.active.parent().prop("aria-hidden", true).prop("aria-expanded", false).hide();
320+
this.active.parent().attr("aria-hidden", "true").attr("aria-expanded", "false").hide();
321321
this.focus(event, newItem);
322322
return true;
323323
}

ui/jquery.ui.menubar.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ $.widget( "ui.menubar", {
4848
}
4949
})
5050
.hide()
51-
.prop({
52-
"aria-hidden": true,
53-
"aria-expanded": false
51+
.attr({
52+
"aria-hidden": "true",
53+
"aria-expanded": "false"
5454
})
5555
.bind( "keydown.menubar", function( event ) {
5656
var menu = $( this );
@@ -108,7 +108,7 @@ $.widget( "ui.menubar", {
108108
})
109109
.addClass( "ui-button ui-widget ui-button-text-only ui-menubar-link" )
110110
.attr( "role", "menuitem" )
111-
.prop( "aria-haspopup", true )
111+
.attr( "aria-haspopup", "true" )
112112
.wrapInner( "<span class='ui-button-text'></span>" );
113113

114114
// TODO review if these options are a good choice, maybe they can be merged
@@ -158,7 +158,7 @@ $.widget( "ui.menubar", {
158158
.unbind( ".menubar" )
159159
.removeClass( "ui-button ui-widget ui-button-text-only ui-menubar-link ui-state-default" )
160160
.removeAttr( "role" )
161-
.removeProp( "aria-haspopup" )
161+
.removeAttr( "aria-haspopup" )
162162
// TODO unwrap?
163163
.children( "span.ui-button-text" ).each(function( i, e ) {
164164
var item = $( this );
@@ -170,8 +170,8 @@ $.widget( "ui.menubar", {
170170
this.element.find( ":ui-menu" )
171171
.menu( "destroy" )
172172
.show()
173-
.removeProp( "aria-hidden" )
174-
.removeProp( "aria-expanded" )
173+
.removeAttr( "aria-hidden" )
174+
.removeAttr( "aria-expanded" )
175175
.removeAttr( "tabindex" )
176176
.unbind( ".menubar" );
177177
},
@@ -182,9 +182,9 @@ $.widget( "ui.menubar", {
182182
this.active
183183
.menu( "closeAll" )
184184
.hide()
185-
.prop({
186-
"aria-hidden": true,
187-
"aria-expanded": false
185+
.attr({
186+
"aria-hidden": "true",
187+
"aria-expanded": "false"
188188
});
189189
this.active
190190
.prev()
@@ -204,9 +204,9 @@ $.widget( "ui.menubar", {
204204
this.active
205205
.menu( "closeAll" )
206206
.hide()
207-
.prop({
208-
"aria-hidden": true,
209-
"aria-expanded": false
207+
.attr({
208+
"aria-hidden": "true",
209+
"aria-expanded": "false"
210210
});
211211
this.active
212212
.prev()
@@ -221,8 +221,8 @@ $.widget( "ui.menubar", {
221221
at: "left bottom",
222222
of: button
223223
})
224-
.removeProp( "aria-hidden" )
225-
.prop( "aria-expanded", true )
224+
.removeAttr( "aria-hidden" )
225+
.attr( "aria-expanded", "true" )
226226
.menu("focus", event, menu.children( "li" ).first() )
227227
// TODO need a comment here why both events are triggered
228228
.focus()

ui/jquery.ui.popup.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $.widget( "ui.popup", {
4141
}
4242

4343
this.options.trigger
44-
.prop( "aria-haspopup", true )
44+
.attr( "aria-haspopup", "true" )
4545
.attr( "aria-owns", this.element.attr( "id" ) );
4646

4747
this.element
@@ -118,11 +118,11 @@ $.widget( "ui.popup", {
118118
this.element
119119
.show()
120120
.removeClass( "ui-popup" )
121-
.removeProp( "aria-hidden" )
122-
.removeProp( "aria-expanded" );
121+
.removeAttr( "aria-hidden" )
122+
.removeAttr( "aria-expanded" );
123123

124124
this.options.trigger
125-
.removeProp( "aria-haspopup" )
125+
.removeAttr( "aria-haspopup" )
126126
.removeAttr( "aria-owns" );
127127

128128
if ( this.generatedId ) {
@@ -140,8 +140,8 @@ $.widget( "ui.popup", {
140140

141141
this.element
142142
.show()
143-
.prop( "aria-hidden", false )
144-
.prop( "aria-expanded", true )
143+
.attr( "aria-hidden", "false" )
144+
.attr( "aria-expanded", "true" )
145145
.position( position )
146146
// TODO find a focussable child, otherwise put focus on element, add tabIndex=0 if not focussable
147147
.focus();
@@ -160,8 +160,8 @@ $.widget( "ui.popup", {
160160
close: function( event ) {
161161
this.element
162162
.hide()
163-
.prop( "aria-hidden", true )
164-
.prop( "aria-expanded", false );
163+
.attr( "aria-hidden", "true" )
164+
.attr( "aria-expanded", "false" );
165165

166166
this.options.trigger.attr("tabindex", 0);
167167

0 commit comments

Comments
 (0)