Permalink
Browse files

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.
  • Loading branch information...
1 parent 2df590e commit f9ea869ab5e887dad28088f6b477fa2ecac747a9 @mgol mgol committed with mgol May 29, 2016
Showing with 10 additions and 1 deletion.
  1. +10 −1 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 ) {

0 comments on commit f9ea869

Please sign in to comment.