Tests: Make tests not trigger Migrate 4.0.0-beta.1 warnings

Changes:
* Checkboxradio: Change `.attr( "checked", true )` to
  `.attr( "checked", "checked" )
* Selectmenu: Disable the `boolean-attributes` patch for one assertion where
  it's impossible to avoid

Closes gh-2364
This commit is contained in:
Michał Gołębiowski-Owczarek
2025-08-18 22:12:36 +02:00
committed by GitHub
parent 73d063677a
commit a7ac081009
2 changed files with 20 additions and 3 deletions

View File

@@ -97,7 +97,7 @@ QUnit.test( "icon - default unchecked", function( assert ) {
} );
QUnit.test( "icon - default checked", function( assert ) {
var checkbox = $( "#checkbox-option-icon" ).attr( "checked", true );
var checkbox = $( "#checkbox-option-icon" ).attr( "checked", "checked" );
assert.expect( 2 );

View File

@@ -41,8 +41,25 @@ QUnit.test( "enable / disable", function( assert ) {
element.selectmenu( "disable" );
assert.ok( element.selectmenu( "option", "disabled" ), "disable: widget option" );
assert.ok( [ "disabled", "" ].indexOf( element.attr( "disabled" ) ) !== -1,
"disable: native select disabled" );
// Migrate 4.x warns about reading boolean attributes when their
// value is not their lowercase name - but that's what happens
// when setting the `disabled` property to `true` first; the attribute
// is then set to an empty string. Avoid the warning by temporarily
// disabling the patch.
// In real apps it's discouraged to mix `.prop()` & `.attr()` usage
// for reflected property-attribute pairs.
if ( $.migrateDisablePatches ) {
$.migrateDisablePatches( "boolean-attributes" );
}
assert.ok(
[ "disabled", "" ].indexOf( element.attr( "disabled" ) ) !== -1,
"disable: native select disabled"
);
if ( $.migrateEnablePatches ) {
$.migrateEnablePatches( "boolean-attributes" );
}
assert.equal( button.attr( "aria-disabled" ), "true", "disable: button ARIA" );
assert.equal( button.attr( "tabindex" ), -1, "disable: button tabindex" );
assert.equal( menu.attr( "aria-disabled" ), "true", "disable: menu ARIA" );