Skip to content

Undefine "define.amd" instead of "define", to allow other RequireJS modules to be loaded #746

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

Merged
merged 3 commits into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Make the fix for using DDT with jQuery and RequireJS more focused
When we undefine the entire window.define, modules loaded asynchronously
can randomly fail to register themselves. However, jQuery 2+ checks for
window.define.amd before registering itself as an AMD module, not just
window.define. So, by unsetting window.define.amd instead of
window.define, we don't break define() for other modules and we still
prevent the page-global jQuery from registering itself as an AMD module,
which was the ultimate goal of #591.
  • Loading branch information
Eric Petersen committed Sep 2, 2015
commit 4af527dab5a75f34a645de2b5826e06fc5c7f53c
5 changes: 4 additions & 1 deletion debug_toolbar/static/debug_toolbar/js/jquery_post.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
var djdt = {jQuery: jQuery.noConflict(true)}; window.define = _djdt_define_backup;
var djdt = {jQuery: jQuery.noConflict(true)};
if (typeof(window.define) !== 'undefined') {
window.define.amd = _djdt_define_amd_backup;
}
6 changes: 5 additions & 1 deletion debug_toolbar/static/debug_toolbar/js/jquery_pre.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
var _djdt_define_backup = window.define; window.define = undefined;
var _djdt_define_amd_backup;
if (typeof(window.define) !== 'undefined') {
_djdt_define_amd_backup = window.define.amd;
window.define.amd = undefined;
}