vendor/assets/javascripts/require.js in requirejs-rails-0.7.2 vs vendor/assets/javascripts/require.js in requirejs-rails-0.7.3
- old
+ new
@@ -1,17 +1,17 @@
/** vim: et:ts=4:sw=4:sts=4
- * @license RequireJS 1.0.7 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
+ * @license RequireJS 1.0.8 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
/*jslint strict: false, plusplus: false, sub: true */
/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
var requirejs, require, define;
-(function () {
+(function (undefined) {
//Change this version number for each release.
- var version = "1.0.7",
+ var version = "1.0.8",
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
currDirRegExp = /^\.\//,
jsSuffixRegExp = /\.js$/,
ostring = Object.prototype.toString,
@@ -421,22 +421,23 @@
cb = manager.callback,
map = manager.map,
fullName = map.fullName,
args = manager.deps,
listeners = manager.listeners,
+ execCb = config.requireExecCb || req.execCb,
cjsModule;
//Call the callback to define the module, if necessary.
if (cb && isFunction(cb)) {
if (config.catchError.define) {
try {
- ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
+ ret = execCb(fullName, manager.callback, args, defined[fullName]);
} catch (e) {
err = e;
}
} else {
- ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
+ ret = execCb(fullName, manager.callback, args, defined[fullName]);
}
if (fullName) {
//If setting exports via "module" is in play,
//favor that over return value and exports. After that,
@@ -1172,11 +1173,11 @@
if (map.prefix) {
callPlugin(map.prefix, manager);
} else {
//Regular dependency.
if (!urlFetched[url] && !loaded[fullName]) {
- req.load(context, fullName, url);
+ (config.requireLoad || req.load)(context, fullName, url);
//Mark the URL as fetched, but only if it is
//not an empty: URL, used by the optimizer.
//In that case we need to be sure to call
//load() for each module that is mapped to
@@ -1476,11 +1477,12 @@
//Normalize module name if have a base relative module name to work from.
moduleName = normalize(moduleName, relModuleMap && relModuleMap.fullName);
//If a colon is in the URL, it indicates a protocol is used and it is just
- //an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file.
+ //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
+ //or ends with .js, then assume the user meant to use an url and not a module id.
//The slash is important for protocol-less URLs as well as full paths.
if (req.jsExtRegExp.test(moduleName)) {
//Just a plain path, not module name lookup, so just return it.
//Add extension if it is included. This is a bit wonky, only non-.js things pass
//an extension, this method probably needs to be reworked.
@@ -1512,11 +1514,11 @@
}
}
//Join the path parts together, then figure out if baseUrl is needed.
url = syms.join("/") + (ext || ".js");
- url = (url.charAt(0) === '/' || url.match(/^\w+:/) ? "" : config.baseUrl) + url;
+ url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? "" : config.baseUrl) + url;
}
return config.urlArgs ? url +
((url.indexOf('?') === -1 ? '?' : '&') +
config.urlArgs) : url;
@@ -1876,10 +1878,18 @@
//addEventListener support, which fire the onload event for a
//script right after the script execution. See:
//https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
//script execution mode.
- if (node.attachEvent && !isOpera) {
+ if (node.attachEvent &&
+ // check if node.attachEvent is artificially added by custom script or
+ // natively supported by browser
+ // read https://github.com/jrburke/requirejs/issues/187
+ // if we can NOT find [native code] then it must NOT natively supported.
+ // in IE8, node.attachEvent does not have toString()
+ // TODO: a better way to check interactive mode
+ !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code]') < 0) &&
+ !isOpera) {
//Probably IE. IE (at least 6-8) do not fire
//script onload right after executing the script, so
//we cannot tie the anonymous define call to a name.
//However, IE reports the script as being in "interactive"
//readyState at the time of the define call.