Skip to content

Commit f9ea869

Browse files
committed
Tests: Remove side-effects of one attributes test
One test in the attribute module was overwriting jQuery.expr.attrHandle.checked and wasn't restoring the original state after it finished. It started causing issues for another checked-related test.
1 parent 2df590e commit f9ea869

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/unit/attributes.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,9 @@ QUnit.test( "attr(non-ASCII)", function( assert ) {
487487
QUnit.test( "attr - extending the boolean attrHandle", function( assert ) {
488488
assert.expect( 1 );
489489
var called = false,
490-
_handle = jQuery.expr.attrHandle.checked || $.noop;
490+
origAttrHandleHadChecked = "checked" in jQuery.expr.attrHandle,
491+
origAttrHandleChecked = jQuery.expr.attrHandle.checked,
492+
_handle = origAttrHandleChecked || $.noop;
491493
jQuery.expr.attrHandle.checked = function() {
492494
called = true;
493495
_handle.apply( this, arguments );
@@ -496,6 +498,13 @@ QUnit.test( "attr - extending the boolean attrHandle", function( assert ) {
496498
called = false;
497499
jQuery( "#qunit-fixture input" ).attr( "checked" );
498500
assert.ok( called, "The boolean attrHandle does not drop custom attrHandles" );
501+
502+
if ( origAttrHandleHadChecked ) {
503+
jQuery.expr.attrHandle.checked = origAttrHandleChecked;
504+
} else {
505+
delete jQuery.expr.attrHandle.checked;
506+
}
507+
499508
} );
500509

501510
QUnit.test( "attr(String, Object) - Loaded via XML document", function( assert ) {

0 commit comments

Comments
 (0)