1
1
/** 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.
3
3
* Available via the MIT or new BSD license.
4
4
* see: http://github.com/jrburke/requirejs for details
5
5
*/
@@ -10,9 +10,9 @@ var requirejs, require, define;
10
10
( function ( global ) {
11
11
'use strict' ;
12
12
13
- var version = '2.0.2 ' ,
13
+ var version = '2.0.4 ' ,
14
14
commentRegExp = / ( \/ \* ( [ \s \S ] * ?) \* \/ | ( [ ^ : ] | ^ ) \/ \/ ( .* ) $ ) / mg,
15
- cjsRequireRegExp = / r e q u i r e \s * \( \s * [ " ' ] ( [ ^ ' " \s ] + ) [ " ' ] \s * \) / g,
15
+ cjsRequireRegExp = / [ ^ . ] \s * r e q u i r e \s * \( \s * [ " ' ] ( [ ^ ' " \s ] + ) [ " ' ] \s * \) / g,
16
16
jsSuffixRegExp = / \. j s $ / ,
17
17
currDirRegExp = / ^ \. \/ / ,
18
18
ostring = Object . prototype . toString ,
@@ -288,6 +288,7 @@ var requirejs, require, define;
288
288
*/
289
289
function normalize ( name , baseName , applyMap ) {
290
290
var baseParts = baseName && baseName . split ( '/' ) ,
291
+ normalizedBaseParts = baseParts ,
291
292
map = config . map ,
292
293
starMap = map && map [ '*' ] ,
293
294
pkgName , pkgConfig , mapValue , nameParts , i , j , nameSegment ,
@@ -302,17 +303,17 @@ var requirejs, require, define;
302
303
if ( config . pkgs [ baseName ] ) {
303
304
//If the baseName is a package name, then just treat it as one
304
305
//name to concat the name with.
305
- baseParts = [ baseName ] ;
306
+ normalizedBaseParts = baseParts = [ baseName ] ;
306
307
} else {
307
308
//Convert baseName to array, and lop off the last part,
308
309
//so that . matches that 'directory' and not name of the baseName's
309
310
//module. For instance, baseName of 'one/two/three', maps to
310
311
//'one/two/three.js', but we want the directory, 'one/two' for
311
312
//this normalization.
312
- baseParts = baseParts . slice ( 0 , baseParts . length - 1 ) ;
313
+ normalizedBaseParts = baseParts . slice ( 0 , baseParts . length - 1 ) ;
313
314
}
314
315
315
- name = baseParts . concat ( name . split ( '/' ) ) ;
316
+ name = normalizedBaseParts . concat ( name . split ( '/' ) ) ;
316
317
trimDots ( name ) ;
317
318
318
319
//Some use of packages may use a . path to reference the
@@ -450,17 +451,7 @@ var requirejs, require, define;
450
451
} else {
451
452
//A regular module.
452
453
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 ) ;
464
455
}
465
456
}
466
457
@@ -1583,20 +1574,21 @@ var requirejs, require, define;
1583
1574
moduleNamePlusExt = moduleNamePlusExt . substring ( 0 , index ) ;
1584
1575
}
1585
1576
1586
- return context . nameToUrl ( moduleNamePlusExt , ext , relModuleMap ) ;
1577
+ return context . nameToUrl ( normalize ( moduleNamePlusExt , relModuleMap && relModuleMap . id , true ) ,
1578
+ ext ) ;
1587
1579
} ,
1588
1580
1589
1581
/**
1590
1582
* Converts a module name to a file path. Supports cases where
1591
1583
* 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.
1592
1587
*/
1593
- nameToUrl : function ( moduleName , ext , relModuleMap ) {
1588
+ nameToUrl : function ( moduleName , ext ) {
1594
1589
var paths , pkgs , pkg , pkgPath , syms , i , parentModule , url ,
1595
1590
parentPath ;
1596
1591
1597
- //Normalize module name if have a base relative module name to work from.
1598
- moduleName = normalize ( moduleName , relModuleMap && relModuleMap . id , true ) ;
1599
-
1600
1592
//If a colon is in the URL, it indicates a protocol is used and it is just
1601
1593
//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
1602
1594
//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;
1822
1814
document . createElement ( 'script' ) ;
1823
1815
node . type = config . scriptType || 'text/javascript' ;
1824
1816
node . charset = 'utf-8' ;
1817
+ node . async = true ;
1825
1818
1826
1819
node . setAttribute ( 'data-requirecontext' , context . contextName ) ;
1827
1820
node . setAttribute ( 'data-requiremodule' , moduleName ) ;
@@ -1924,21 +1917,21 @@ var requirejs, require, define;
1924
1917
//baseUrl, if it is not already set.
1925
1918
dataMain = script . getAttribute ( 'data-main' ) ;
1926
1919
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
-
1934
1920
//Set final baseUrl if there is not already an explicit one.
1935
1921
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
+
1936
1928
cfg . baseUrl = subPath ;
1929
+ dataMain = mainScript ;
1937
1930
}
1938
1931
1939
1932
//Strip off any trailing .js since dataMain is now
1940
1933
//like a module name.
1941
- dataMain = mainScript . replace ( jsSuffixRegExp , '' ) ;
1934
+ dataMain = dataMain . replace ( jsSuffixRegExp , '' ) ;
1942
1935
1943
1936
//Put the data-main script in the files to load.
1944
1937
cfg . deps = cfg . deps ? cfg . deps . concat ( dataMain ) : [ dataMain ] ;
0 commit comments