11/** vim: et:ts=4:sw=4:sts=4
2- * @license RequireJS 2.1.10 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
2+ * @license RequireJS 2.1.14 Copyright (c) 2010-2014, 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 */
@@ -12,7 +12,7 @@ var requirejs, require, define;
1212( function ( global ) {
1313 var req , s , head , baseElement , dataMain , src ,
1414 interactiveScript , currentlyAddingScript , mainScript , subPath ,
15- version = '2.1.10 ' ,
15+ version = '2.1.14 ' ,
1616 commentRegExp = / ( \/ \* ( [ \s \S ] * ?) \* \/ | ( [ ^ : ] | ^ ) \/ \/ ( .* ) $ ) / mg,
1717 cjsRequireRegExp = / [ ^ . ] \s * r e q u i r e \s * \( \s * [ " ' ] ( [ ^ ' " \s ] + ) [ " ' ] \s * \) / g,
1818 jsSuffixRegExp = / \. j s $ / ,
@@ -141,7 +141,7 @@ var requirejs, require, define;
141141 throw err ;
142142 }
143143
144- //Allow getting a global that expressed in
144+ //Allow getting a global that is expressed in
145145 //dot notation, like 'a.b.c'.
146146 function getGlobal ( value ) {
147147 if ( ! value ) {
@@ -180,7 +180,7 @@ var requirejs, require, define;
180180
181181 if ( typeof requirejs !== 'undefined' ) {
182182 if ( isFunction ( requirejs ) ) {
183- //Do not overwrite and existing requirejs instance.
183+ //Do not overwrite an existing requirejs instance.
184184 return ;
185185 }
186186 cfg = requirejs ;
@@ -232,21 +232,20 @@ var requirejs, require, define;
232232 * @param {Array } ary the array of path segments.
233233 */
234234 function trimDots ( ary ) {
235- var i , part , length = ary . length ;
236- for ( i = 0 ; i < length ; i ++ ) {
235+ var i , part ;
236+ for ( i = 0 ; i < ary . length ; i ++ ) {
237237 part = ary [ i ] ;
238238 if ( part === '.' ) {
239239 ary . splice ( i , 1 ) ;
240240 i -= 1 ;
241241 } else if ( part === '..' ) {
242- if ( i === 1 && ( ary [ 2 ] === '..' || ary [ 0 ] === '..' ) ) {
243- //End of the line. Keep at least one non-dot
244- //path segment at the front so it can be mapped
245- //correctly to disk. Otherwise, there is likely
246- //no path mapping for a path starting with '..'.
247- //This can still fail, but catches the most reasonable
248- //uses of ..
249- break ;
242+ // If at the start, or previous value is still ..,
243+ // keep them so that when converted to a path it may
244+ // still work when converted to a path, even though
245+ // as an ID it is less than ideal. In larger point
246+ // releases, may be better to just kick out an error.
247+ if ( i === 0 || ( i == 1 && ary [ 2 ] === '..' ) || ary [ i - 1 ] === '..' ) {
248+ continue ;
250249 } else if ( i > 0 ) {
251250 ary . splice ( i - 1 , 2 ) ;
252251 i -= 2 ;
@@ -267,43 +266,37 @@ var requirejs, require, define;
267266 */
268267 function normalize ( name , baseName , applyMap ) {
269268 var pkgMain , mapValue , nameParts , i , j , nameSegment , lastIndex ,
270- foundMap , foundI , foundStarMap , starI ,
271- baseParts = baseName && baseName . split ( '/' ) ,
272- normalizedBaseParts = baseParts ,
269+ foundMap , foundI , foundStarMap , starI , normalizedBaseParts ,
270+ baseParts = ( baseName && baseName . split ( '/' ) ) ,
273271 map = config . map ,
274272 starMap = map && map [ '*' ] ;
275273
276274 //Adjust any relative paths.
277- if ( name && name . charAt ( 0 ) === '.' ) {
278- //If have a base name, try to normalize against it,
279- //otherwise, assume it is a top-level require that will
280- //be relative to baseUrl in the end.
281- if ( baseName ) {
275+ if ( name ) {
276+ name = name . split ( '/' ) ;
277+ lastIndex = name . length - 1 ;
278+
279+ // If wanting node ID compatibility, strip .js from end
280+ // of IDs. Have to do this here, and not in nameToUrl
281+ // because node allows either .js or non .js to map
282+ // to same file.
283+ if ( config . nodeIdCompat && jsSuffixRegExp . test ( name [ lastIndex ] ) ) {
284+ name [ lastIndex ] = name [ lastIndex ] . replace ( jsSuffixRegExp , '' ) ;
285+ }
286+
287+ // Starts with a '.' so need the baseName
288+ if ( name [ 0 ] . charAt ( 0 ) === '.' && baseParts ) {
282289 //Convert baseName to array, and lop off the last part,
283290 //so that . matches that 'directory' and not name of the baseName's
284291 //module. For instance, baseName of 'one/two/three', maps to
285292 //'one/two/three.js', but we want the directory, 'one/two' for
286293 //this normalization.
287294 normalizedBaseParts = baseParts . slice ( 0 , baseParts . length - 1 ) ;
288- name = name . split ( '/' ) ;
289- lastIndex = name . length - 1 ;
290-
291- // If wanting node ID compatibility, strip .js from end
292- // of IDs. Have to do this here, and not in nameToUrl
293- // because node allows either .js or non .js to map
294- // to same file.
295- if ( config . nodeIdCompat && jsSuffixRegExp . test ( name [ lastIndex ] ) ) {
296- name [ lastIndex ] = name [ lastIndex ] . replace ( jsSuffixRegExp , '' ) ;
297- }
298-
299295 name = normalizedBaseParts . concat ( name ) ;
300- trimDots ( name ) ;
301- name = name . join ( '/' ) ;
302- } else if ( name . indexOf ( './' ) === 0 ) {
303- // No baseName, so this is ID is resolved relative
304- // to baseUrl, pull off the leading dot.
305- name = name . substring ( 2 ) ;
306296 }
297+
298+ trimDots ( name ) ;
299+ name = name . join ( '/' ) ;
307300 }
308301
309302 //Apply map config if available.
@@ -379,7 +372,13 @@ var requirejs, require, define;
379372 //retry
380373 pathConfig . shift ( ) ;
381374 context . require . undef ( id ) ;
382- context . require ( [ id ] ) ;
375+
376+ //Custom require that does not do map translation, since
377+ //ID is "absolute", already mapped/resolved.
378+ context . makeRequire ( null , {
379+ skipMap : true
380+ } ) ( [ id ] ) ;
381+
383382 return true ;
384383 }
385384 }
@@ -445,7 +444,16 @@ var requirejs, require, define;
445444 return normalize ( name , parentName , applyMap ) ;
446445 } ) ;
447446 } else {
448- normalizedName = normalize ( name , parentName , applyMap ) ;
447+ // If nested plugin references, then do not try to
448+ // normalize, as it will not normalize correctly. This
449+ // places a restriction on resourceIds, and the longer
450+ // term solution is not to normalize until plugins are
451+ // loaded and all normalizations to allow for async
452+ // loading of a loader plugin. But for now, fixes the
453+ // common uses. Details in #1131
454+ normalizedName = name . indexOf ( '!' ) === - 1 ?
455+ normalize ( name , parentName , applyMap ) :
456+ name ;
449457 }
450458 } else {
451459 //A regular module.
@@ -567,7 +575,7 @@ var requirejs, require, define;
567575 mod . usingExports = true ;
568576 if ( mod . map . isDefine ) {
569577 if ( mod . exports ) {
570- return mod . exports ;
578+ return ( defined [ mod . map . id ] = mod . exports ) ;
571579 } else {
572580 return ( mod . exports = defined [ mod . map . id ] = { } ) ;
573581 }
@@ -583,7 +591,7 @@ var requirejs, require, define;
583591 config : function ( ) {
584592 return getOwn ( config . config , mod . map . id ) || { } ;
585593 } ,
586- exports : handlers . exports ( mod )
594+ exports : mod . exports || ( mod . exports = { } )
587595 } ) ;
588596 }
589597 }
@@ -1502,7 +1510,7 @@ var requirejs, require, define;
15021510 /**
15031511 * Called to enable a module if it is still in the registry
15041512 * awaiting enablement. A second arg, parent, the parent module,
1505- * is passed in for context, when this method is overriden by
1513+ * is passed in for context, when this method is overridden by
15061514 * the optimizer. Not shown here to keep code compact.
15071515 */
15081516 enable : function ( depMap ) {
0 commit comments