Skip to content

Commit 4af527d

Browse files
author
Eric Petersen
committed
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.
1 parent 6f234e7 commit 4af527d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
var djdt = {jQuery: jQuery.noConflict(true)}; window.define = _djdt_define_backup;
1+
var djdt = {jQuery: jQuery.noConflict(true)};
2+
if (typeof(window.define) !== 'undefined') {
3+
window.define.amd = _djdt_define_amd_backup;
4+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
var _djdt_define_backup = window.define; window.define = undefined;
1+
var _djdt_define_amd_backup;
2+
if (typeof(window.define) !== 'undefined') {
3+
_djdt_define_amd_backup = window.define.amd;
4+
window.define.amd = undefined;
5+
}

0 commit comments

Comments
 (0)