8000 Tests: Cleanup `window` & `document` handlers in a new event test · jquery/jquery@c1c0598 · GitHub
[go: up one dir, main page]

Skip to content

Commit c1c0598

Browse files
committed
Tests: Cleanup window & document handlers in a new event test
The "focusin on document & window" test didn't cleanup `focusout` handlers on `window` & `document`. This has been fixed. Ref gh-4657
1 parent 46ba70c commit c1c0598

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/unit/event.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,16 +2600,16 @@ QUnit.test( "focusin on document & window", function( assert ) {
26002600
var counter = 0,
26012601
input = jQuery( "<input />" );
26022602

2603+
function increment() {
2604+
counter++;
2605+
}
2606+
26032607
input.appendTo( "#qunit-fixture" );
26042608

26052609
input[ 0 ].focus();
26062610

2607-
jQuery( window ).on( "focusout", function() {
2608-
counter++;
2609-
} );
2610-
jQuery( document ).on( "focusout", function() {
2611-
counter++;
2612-
} );
2611+
jQuery( window ).on( "focusout", increment );
2612+
jQuery( document ).on( "focusout", increment );
26132613

26142614
input[ 0 ].blur();
26152615

@@ -2620,6 +2620,9 @@ QUnit.test( "focusin on document & window", function( assert ) {
26202620

26212621
assert.strictEqual( counter, 2,
26222622
"focusout handlers on document/window fired once only" );
2623+
2624+
jQuery( window ).off( "focusout", increment );
2625+
jQuery( document ).off( "focusout", increment );
26232626
} );
26242627

26252628
testIframe(

0 commit comments

Comments
 (0)
0