Skip to content

Commit e313aaa

Browse files
committed
[Bugfix release] Ensure jQuery “monkey patch” are included via modules.
This both tidies up the code, but also ensures embroider compatibility For those users with ember 2.27.x but still have jQuery
1 parent 16118c3 commit e313aaa

File tree

3 files changed

+22
-45
lines changed

3 files changed

+22
-45
lines changed

addon-test-support/@ember/test-helpers/settled.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import { _backburner } from '@ember/runloop';
33
import Ember from 'ember';
44

5+
import EmberApplication from '@ember/application';
6+
57
import { nextTick } from './-utils';
68
import waitUntil from './wait-until';
79
import { hasPendingTransitions } from './setup-application-context';
@@ -30,6 +32,26 @@ const _internalPendingRequests = (() => {
3032
return () => 0;
3133
})();
3234

35+
if (typeof jQuery !== 'undefined' && _internalPendingRequests) {
36+
// This exists to ensure that the AJAX listeners setup by Ember itself
37+
// (which as of 2.17 are not properly torn down) get cleared and released
38+
// when the application is destroyed. Without this, any AJAX requests
39+
// that happen _between_ acceptance tests will always share
40+
// `pendingRequests`.
41+
//
42+
// This can be removed once Ember 4.0.0 is released
43+
EmberApplication.reopen({
44+
willDestroy() {
45+
jQuery(document).off('ajaxSend', _internalPendingRequests.incrementPendingRequests);
46+
jQuery(document).off('ajaxComplete', _internalPendingRequests.decrementPendingRequests);
47+
48+
_internalPendingRequests.clearPendingRequests();
49+
50+
this._super(...arguments);
51+
},
52+
});
53+
}
54+
3355
let requests: XMLHttpRequest[];
3456

3557
/**

index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ const debugTree = BroccoliDebug.buildDebugCallback('ember-test-helpers');
66
module.exports = {
77
name: require('./package').name,
88

9-
included() {
10-
this._super.included.apply(this, arguments);
11-
12-
this.import('vendor/monkey-patches.js', { type: 'test' });
13-
},
14-
159
treeForAddonTestSupport(tree) {
1610
// intentionally not calling _super here
1711
// so that can have our `import`'s be

vendor/monkey-patches.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)