forked from ibm-js/requirejs-dplugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaybe.js
30 lines (27 loc) · 735 Bytes
/
maybe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
define({
load: function (name, require, onload) {
if (require.on) {
// Dojo
// code from https://bugs.dojotoolkit.org/attachment/ticket/16416/t16416.html courtesy of rcgill
require.on("error", function () {
if (!require.modules[name].executed) {
// yep, it had a problem; therefore...
// put it back into the "unloaded" state
require.undef(name);
// define it another way..
define(name, [], function () {
return 0;
});
// this gets the loader to notice that the module showed up without being requested
require([name]);
}
});
}
// RequireJS and Dojo
require([name], function (value) {
onload(value);
}, function () {
onload(undefined);
});
}
});