Skip to content

Commit eb3167f

Browse files
committed
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
1 parent 2037c3a commit eb3167f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

tests/unit/checkboxradio/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ QUnit.test( "icon - default unchecked", function( assert ) {
9797
} );
9898

9999
QUnit.test( "icon - default checked", function( assert ) {
100-
var checkbox = $( "#checkbox-option-icon" ).attr( "checked", true );
100+
var checkbox = $( "#checkbox-option-icon" ).attr( "checked", "checked" );
101101

102102
assert.expect( 2 );
103103

tests/unit/selectmenu/methods.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,24 @@ QUnit.test( "enable / disable", function( assert ) {
4141

4242
element.selectmenu( "disable" );
4343
assert.ok( element.selectmenu( "option", "disabled" ), "disable: widget option" );
44-
assert.ok( [ "disabled", "" ].indexOf( element.attr( "disabled" ) ) !== -1,
45-
"disable: native select disabled" );
44+
45+
if ( $.migrateDisablePatches ) {
46+
47+
// Migrate 4.x warns about reading boolean attributes when their
48+
// value is not their lowercase name - but that's what happens
49+
// wheh setting the `disabled` property to `true` first; the attribute
50+
// is then set to an empty string. Avoid the warning by temporarily
51+
// disabling the patch.
52+
// In real apps it's discouraged to mix `.prop()` & `.attr()` usage
53+
// for reflected property-attribute pairs.
54+
$.migrateDisablePatches( "boolean-attributes" );
55+
assert.ok(
56+
[ "disabled", "" ].indexOf( element.attr( "disabled" ) ) !== -1,
57+
"disable: native select disabled"
58+
);
59+
$.migrateEnablePatches( "boolean-attributes" );
60+
}
61+
4662
assert.equal( button.attr( "aria-disabled" ), "true", "disable: button ARIA" );
4763
assert.equal( button.attr( "tabindex" ), -1, "disable: button tabindex" );
4864
assert.equal( menu.attr( "aria-disabled" ), "true", "disable: menu ARIA" );

0 commit comments

Comments
 (0)