Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 9424e74

Browse files
committed
Updating require.js to 2.0.4
1 parent b063c14 commit 9424e74

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

vendor/assets/javascripts/require.js

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** vim: et:ts=4:sw=4:sts=4
2-
* @license RequireJS 2.0.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
2+
* @license RequireJS 2.0.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -10,9 +10,9 @@ var requirejs, require, define;
1010
(function (global) {
1111
'use strict';
1212

13-
var version = '2.0.2',
13+
var version = '2.0.4',
1414
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
15-
cjsRequireRegExp = /require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
15+
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
1616
jsSuffixRegExp = /\.js$/,
1717
currDirRegExp = /^\.\//,
1818
ostring = Object.prototype.toString,
@@ -288,6 +288,7 @@ var requirejs, require, define;
288288
*/
289289
function normalize(name, baseName, applyMap) {
290290
var baseParts = baseName && baseName.split('/'),
291+
normalizedBaseParts = baseParts,
291292
map = config.map,
292293
starMap = map && map['*'],
293294
pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
@@ -302,17 +303,17 @@ var requirejs, require, define;
302303
if (config.pkgs[baseName]) {
303304
//If the baseName is a package name, then just treat it as one
304305
//name to concat the name with.
305-
baseParts = [baseName];
306+
normalizedBaseParts = baseParts = [baseName];
306307
} else {
307308
//Convert baseName to array, and lop off the last part,
308309
//so that . matches that 'directory' and not name of the baseName's
309310
//module. For instance, baseName of 'one/two/three', maps to
310311
//'one/two/three.js', but we want the directory, 'one/two' for
311312
//this normalization.
312-
baseParts = baseParts.slice(0, baseParts.length - 1);
313+
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
313314
}
314315

315-
name = baseParts.concat(name.split('/'));
316+
name = normalizedBaseParts.concat(name.split('/'));
316317
trimDots(name);
317318

318319
//Some use of packages may use a . path to reference the
@@ -450,17 +451,7 @@ var requirejs, require, define;
450451
} else {
451452
//A regular module.
452453
normalizedName = normalize(name, parentName, applyMap);
453-
454-
//Calculate url for the module, if it has a name.
455-
//Use name here since nameToUrl also calls normalize,
456-
//and for relative names that are outside the baseUrl
457-
//this causes havoc. Was thinking of just removing
458-
//parentModuleMap to avoid extra normalization, but
459-
//normalize() still does a dot removal because of
460-
//issue #142, so just pass in name here and redo
461-
//the normalization. Paths outside baseUrl are just
462-
//messy to support.
463-
url = context.nameToUrl(name, null, parentModuleMap);
454+
url = context.nameToUrl(normalizedName);
464455
}
465456
}
466457

@@ -1583,20 +1574,21 @@ var requirejs, require, define;
15831574
moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
15841575
}
15851576

1586-
return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap);
1577+
return context.nameToUrl(normalize(moduleNamePlusExt, relModuleMap && relModuleMap.id, true),
1578+
ext);
15871579
},
15881580

15891581
/**
15901582
* Converts a module name to a file path. Supports cases where
15911583
* moduleName may actually be just an URL.
1584+
* Note that it **does not** call normalize on the moduleName,
1585+
* it is assumed to have already been normalized. This is an
1586+
* internal API, not a public one. Use toUrl for the public API.
15921587
*/
1593-
nameToUrl: function (moduleName, ext, relModuleMap) {
1588+
nameToUrl: function (moduleName, ext) {
15941589
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
15951590
parentPath;
15961591

1597-
//Normalize module name if have a base relative module name to work from.
1598-
moduleName = normalize(moduleName, relModuleMap && relModuleMap.id, true);
1599-
16001592
//If a colon is in the URL, it indicates a protocol is used and it is just
16011593
//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
16021594
//or ends with .js, then assume the user meant to use an url and not a module id.
@@ -1822,6 +1814,7 @@ var requirejs, require, define;
18221814
document.createElement('script');
18231815
node.type = config.scriptType || 'text/javascript';
18241816
node.charset = 'utf-8';
1817+
node.async = true;
18251818

18261819
node.setAttribute('data-requirecontext', context.contextName);
18271820
node.setAttribute('data-requiremodule', moduleName);
@@ -1924,21 +1917,21 @@ var requirejs, require, define;
19241917
//baseUrl, if it is not already set.
19251918
dataMain = script.getAttribute('data-main');
19261919
if (dataMain) {
1927-
1928-
//Pull off the directory of data-main for use as the
1929-
//baseUrl.
1930-
src = dataMain.split('/');
1931-
mainScript = src.pop();
1932-
subPath = src.length ? src.join('/') + '/' : './';
1933-
19341920
//Set final baseUrl if there is not already an explicit one.
19351921
if (!cfg.baseUrl) {
1922+
//Pull off the directory of data-main for use as the
1923+
//baseUrl.
1924+
src = dataMain.split('/');
1925+
mainScript = src.pop();
1926+
subPath = src.length ? src.join('/') + '/' : './';
1927+
19361928
cfg.baseUrl = subPath;
1929+
dataMain = mainScript;
19371930
}
19381931

19391932
//Strip off any trailing .js since dataMain is now
19401933
//like a module name.
1941-
dataMain = mainScript.replace(jsSuffixRegExp, '');
1934+
dataMain = dataMain.replace(jsSuffixRegExp, '');
19421935

19431936
//Put the data-main script in the files to load.
19441937
cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];

0 commit comments

Comments
 (0)