Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Guard jQuery access in setupForTesting. #15065

Merged
merged 1 commit into from
Mar 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/ember-testing/lib/setup_for_testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export default function setupForTesting() {
setAdapter((typeof self.QUnit === 'undefined') ? new Adapter() : new QUnitAdapter());
}

jQuery(document).off('ajaxSend', incrementPendingRequests);
jQuery(document).off('ajaxComplete', decrementPendingRequests);
if (jQuery) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you do import { jQuery } from 'ember-views'; if there is no jquery? What does that import?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cibernox - Yes, it exports undefined in that case you can see (from here) that it basically does:

let jQuery

export default jQuery

jQuery(document).off('ajaxSend', incrementPendingRequests);
jQuery(document).off('ajaxComplete', decrementPendingRequests);

clearPendingRequests();
clearPendingRequests();

jQuery(document).on('ajaxSend', incrementPendingRequests);
jQuery(document).on('ajaxComplete', decrementPendingRequests);
jQuery(document).on('ajaxSend', incrementPendingRequests);
jQuery(document).on('ajaxComplete', decrementPendingRequests);
}
}