aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/attributes.js
diff options
context:
space:
mode:
authorMichał Gołębiowski <m.goleb@gmail.com>2016-05-29 22:50:28 +0200
committerMichał Gołębiowski <m.goleb@gmail.com>2016-06-03 11:51:33 +0200
commitf9ea869ab5e887dad28088f6b477fa2ecac747a9 (patch)
tree88f490ccacf61f9c40481d29b271693690bdee66 /test/unit/attributes.js
parent2df590e4ecfb8874b1deaca26d3c4cc2b7f7b140 (diff)
downloadjquery-f9ea869ab5e887dad28088f6b477fa2ecac747a9.tar.gz
jquery-f9ea869ab5e887dad28088f6b477fa2ecac747a9.zip
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.
Diffstat (limited to 'test/unit/attributes.js')
-rw-r--r--test/unit/attributes.js11
1 files changed, 10 insertions, 1 deletions
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 ) {