aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/qunit.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2025-03-21 00:03:17 +0100
committerGitHub <noreply@github.com>2025-03-21 00:03:17 +0100
commit44de3d325c1ac0c4a841deff0ec03265a0b670f7 (patch)
tree1e2d6714843aead988ec134ecace8a75e01cba24 /tests/lib/qunit.js
parent6843ced12e4051aefbee47cf87fa79794737eb8a (diff)
downloadjquery-ui-44de3d325c1ac0c4a841deff0ec03265a0b670f7.tar.gz
jquery-ui-44de3d325c1ac0c4a841deff0ec03265a0b670f7.zip
Spinner: Prevent double mousewheel & wheel event handling
As of gh-2338, if one has loaded the jQuery MouseWheel plugin, the `mousewheel` handler would fire the `wheel` one, but the `wheel` one would also run in response to the native `wheel` event, resulting in double the distance handled by the spinner. To prevent the issue, only fire the `wheel` handler from inside the `mousewheel` on if the event was triggered by jQuery - jQuery will not care that the underlying event is `wheel` and will only fire handlers for `mousewheel`. Also, add an iframe test using jQuery MouseWheel to not affect all the other tests. Plus, migrate from `QUnit.reset` to `QUnit.done` (see qunitjs/qunit#354). Closes gh-2342 Ref gh-2338
Diffstat (limited to 'tests/lib/qunit.js')
-rw-r--r--tests/lib/qunit.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/lib/qunit.js b/tests/lib/qunit.js
index 6441019bd..c4c96ef58 100644
--- a/tests/lib/qunit.js
+++ b/tests/lib/qunit.js
@@ -7,6 +7,8 @@ define( [
], function( QUnit, $ ) {
"use strict";
+var ajaxSettings = $.ajaxSettings;
+
QUnit.config.autostart = false;
QUnit.config.requireExpects = true;
@@ -34,16 +36,21 @@ QUnit.config.urlConfig.push( {
label: "Enable jquery-migrate"
} );
-QUnit.reset = ( function( reset ) {
- return function() {
+QUnit.testDone( function() {
+
+ // Ensure jQuery events and data on the fixture are properly removed
+ $( "#qunit-fixture" ).empty();
- // Ensure jQuery events and data on the fixture are properly removed
- $( "#qunit-fixture" ).empty();
+ // Remove the iframe fixture
+ $( "#qunit-fixture-iframe" ).remove();
- // Let QUnit reset the fixture
- reset.apply( this, arguments );
- };
-} )( QUnit.reset );
+ // Reset internal $ state
+ if ( ajaxSettings ) {
+ $.ajaxSettings = $.extend( true, {}, ajaxSettings );
+ } else {
+ delete $.ajaxSettings;
+ }
+} );
return QUnit;