From c1c0598d8fde1bb66a257d7e993dd940aa4f4ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski-Owczarek?= Date: Mon, 27 Apr 2020 21:37:06 +0200 Subject: [PATCH] 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 --- test/unit/event.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/unit/event.js b/test/unit/event.js index f0089b5c6..17f15b2a6 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2600,16 +2600,16 @@ QUnit.test( "focusin on document & window", function( assert ) { var counter = 0, input = jQuery( "" ); + function increment() { + counter++; + } + input.appendTo( "#qunit-fixture" ); input[ 0 ].focus(); - jQuery( window ).on( "focusout", function() { - counter++; - } ); - jQuery( document ).on( "focusout", function() { - counter++; - } ); + jQuery( window ).on( "focusout", increment ); + jQuery( document ).on( "focusout", increment ); input[ 0 ].blur(); @@ -2620,6 +2620,9 @@ QUnit.test( "focusin on document & window", function( assert ) { assert.strictEqual( counter, 2, "focusout handlers on document/window fired once only" ); + + jQuery( window ).off( "focusout", increment ); + jQuery( document ).off( "focusout", increment ); } ); testIframe(