Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog: Add aria-modal support #2257

Merged
merged 15 commits into from
Jun 14, 2024
Prev Previous commit
Next Next commit
applying mgol's suggested changes to the aria-modal test
  • Loading branch information
rpkoller committed Jun 14, 2024
commit 42edf77bc3d5b40dfc492a363b8df868f3140a00
33 changes: 25 additions & 8 deletions tests/unit/dialog/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,42 @@ QUnit.test( "ARIA", function( assert ) {
} );

QUnit.test( "aria-modal", function( assert ) {
assert.expect( 3 );
assert.expect( 12 );
mgol marked this conversation as resolved.
Show resolved Hide resolved

mgol marked this conversation as resolved.
Show resolved Hide resolved
var element = $( "<div>" ).dialog( "options", "modal", true ),
var element = $( "<div>" ).dialog( { modal: true } ),
wrapper = element.dialog( "widget" );
assert.equal( wrapper.attr( "aria-modal" ), "true", "aria-modal attribute set to true" );
assert.equal( wrapper.attr( "aria-modal" ), "true", "modal option set to true, aria-modal attribute added" );
element.dialog( "option", "modal", false );
assert.ok( !wrapper.attr( "aria-modal" ), "modal option set to false, aria-modal attribute not added" );
mgol marked this conversation as resolved.
Show resolved Hide resolved
element.dialog( "option", "modal", null );
assert.ok( !wrapper.attr( "aria-modal" ), "modal option not set, aria-modal attribute not added" );
mgol marked this conversation as resolved.
Show resolved Hide resolved
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( "options", "modal", false ),
var element = $( "<div>" ).dialog( { modal: false } ),
wrapper = element.dialog( "widget" );
assert.equal( wrapper.attr( "aria-modal" ), "false", "aria-modal attribute set to false" );
assert.ok( !wrapper.attr( "aria-modal" ), "modal option set to false, aria-modal attribute not added" );
mgol marked this conversation as resolved.
Show resolved Hide resolved
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.ok( !wrapper.attr( "aria-modal" ), "modal option not set, aria-modal attribute not added" );
mgol marked this conversation as resolved.
Show resolved Hide resolved
element.dialog( "option", "modal", false );
assert.ok( !wrapper.attr( "aria-modal" ), "modal option set to false, aria-modal attribute not added" );
mgol marked this conversation as resolved.
Show resolved Hide resolved
element.remove();

var element = $( "<div>" ).dialog( "options", "modal", null ),
var element = $( "<div>" ).dialog(),
wrapper = element.dialog( "widget" );
assert.equal( wrapper.attr( "aria-modal" ), null, "no aria-modal attribute added" );
assert.ok( !wrapper.attr( "aria-modal" ), "modal option not set, aria-modal attribute not added" );
mgol marked this conversation as resolved.
Show resolved Hide resolved
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.ok( !wrapper.attr( "aria-modal" ), "modal option set to false, aria-modal attribute not added" );
mgol marked this conversation as resolved.
Show resolved Hide resolved
element.dialog( "option", "modal", null );
assert.equal( wrapper.attr( "aria-modal" ), null, "modal option not set, aria-modal attribute not added" );
mgol marked this conversation as resolved.
Show resolved Hide resolved
element.remove();
} );


QUnit.test( "widget method", function( assert ) {
assert.expect( 1 );
var dialog = $( "<div>" ).appendTo( "#qunit-fixture" ).dialog();
Expand Down