From f9ea869ab5e887dad28088f6b477fa2ecac747a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski?= Date: Sun, 29 May 2016 22:50:28 +0200 Subject: [PATCH] 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. --- test/unit/attributes.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/unit/attributes.js b/test/unit/attributes.js index d9a036476..45efddfe4 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -487,7 +487,9 @@ QUnit.test( "attr(non-ASCII)", function( assert ) { QUnit.test( "attr - extending the boolean attrHandle", function( assert ) { assert.expect( 1 ); 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() { called = true; _handle.apply( this, arguments ); @@ -496,6 +498,13 @@ QUnit.test( "attr - extending the boolean attrHandle", function( assert ) { called = false; jQuery( "#qunit-fixture input" ).attr( "checked" ); 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 ) {