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.
This commit is contained in:
Michał Gołębiowski 2016-05-29 22:50:28 +02:00 committed by Michał Gołębiowski
parent 2df590e4ec
commit f9ea869ab5

View File

@ -487,7 +487,9 @@ QUnit.test( "attr(non-ASCII)", function( assert ) {
QUnit.test( "attr - extending the boolean attrHandle", function( assert ) { QUnit.test( "attr - extending the boolean attrHandle", function( assert ) {
assert.expect( 1 ); assert.expect( 1 );
var called = false, var called = false,
_handle = jQuery.expr.attrHandle.checked || $.noop; origAttrHandleHadChecked = "checked" in jQuery.expr.attrHandle,
origAttrHandleChecked = jQuery.expr.attrHandle.checked,
_handle = origAttrHandleChecked || $.noop;
jQuery.expr.attrHandle.checked = function() { jQuery.expr.attrHandle.checked = function() {
called = true; called = true;
_handle.apply( this, arguments ); _handle.apply( this, arguments );
@ -496,6 +498,13 @@ QUnit.test( "attr - extending the boolean attrHandle", function( assert ) {
called = false; called = false;
jQuery( "#qunit-fixture input" ).attr( "checked" ); jQuery( "#qunit-fixture input" ).attr( "checked" );
assert.ok( called, "The boolean attrHandle does not drop custom attrHandles" ); assert.ok( called, "The boolean attrHandle does not drop custom attrHandles" );
if ( origAttrHandleHadChecked ) {
jQuery.expr.attrHandle.checked = origAttrHandleChecked;
} else {
delete jQuery.expr.attrHandle.checked;
}
} ); } );
QUnit.test( "attr(String, Object) - Loaded via XML document", function( assert ) { QUnit.test( "attr(String, Object) - Loaded via XML document", function( assert ) {