Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/unit/dialog/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,43 @@ QUnit.test( "ARIA", function( assert ) {
element.remove();
} );

QUnit.test( "aria-modal", function( assert ) {
assert.expect( 12 );

var element = $( "<div>" ).dialog( { modal: true } ),
wrapper = element.dialog( "widget" );
assert.equal( wrapper.attr( "aria-modal" ), "true", "modal option set to true, aria-modal attribute added" );
element.dialog( "option", "modal", false );
assert.equal( wrapper.attr( "aria-modal" ), undefined, "modal option set to false, aria-modal attribute not added" );
element.dialog( "option", "modal", null );
assert.equal( wrapper.attr( "aria-modal" ), undefined, "modal option not set, aria-modal attribute not added" );
element.dialog( "option", "modal", true );
assert.equal( wrapper.attr( "aria-modal" ), "true", "modal option set to true, aria-modal attribute added" );
element.remove();

var element = $( "<div>" ).dialog( { modal: false } ),
wrapper = element.dialog( "widget" );
assert.equal( wrapper.attr( "aria-modal" ), undefined, "modal option set to false, aria-modal attribute not added" );
element.dialog( "option", "modal", true );
assert.equal( wrapper.attr( "aria-modal" ), "true", "modal option set to true, aria-modal attribute added" );
element.dialog( "option", "modal", null );
assert.equal( wrapper.attr( "aria-modal" ), undefined, "modal option not set, aria-modal attribute not added" );
element.dialog( "option", "modal", false );
assert.equal( wrapper.attr( "aria-modal" ), undefined, "modal option set to false, aria-modal attribute not added" );
element.remove();

var element = $( "<div>" ).dialog(),
wrapper = element.dialog( "widget" );
assert.equal( wrapper.attr( "aria-modal" ), undefined, "modal option not set, aria-modal attribute not added" );
element.dialog( "option", "modal", true );
assert.equal( wrapper.attr( "aria-modal" ), "true", "modal option set to true, aria-modal attribute added" );
element.dialog( "option", "modal", false );
assert.equal( wrapper.attr( "aria-modal" ), undefined, "modal option set to false, aria-modal attribute not added" );
element.dialog( "option", "modal", null );
assert.equal( wrapper.attr( "aria-modal" ), null, "modal option not set, aria-modal attribute not added" );
element.remove();
} );

QUnit.test( "widget method", function( assert ) {
assert.expect( 1 );
var dialog = $( "<div>" ).appendTo( "#qunit-fixture" ).dialog();
Expand Down
7 changes: 6 additions & 1 deletion ui/widgets/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ $.widget( "ui.dialog", {

// Setting tabIndex makes the div focusable
tabIndex: -1,
role: "dialog"
role: "dialog",
"aria-modal": this.options.modal ? "true" : null
} )
.appendTo( this._appendTo() );

Expand Down Expand Up @@ -762,6 +763,10 @@ $.widget( "ui.dialog", {
if ( key === "title" ) {
this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
}

if ( key === "modal" ) {
uiDialog.attr( "aria-modal", value ? "true" : null );
}
},

_size: function() {
Expand Down