1
1
/** vim: et:ts=4:sw=4:sts=4
2
- * @license RequireJS 2.1.11 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
2
+ * @license RequireJS 2.1.15 Copyright (c) 2010-2014, 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
*/
@@ -12,7 +12,7 @@ var requirejs, require, define;
12
12
( function ( global ) {
13
13
var req , s , head , baseElement , dataMain , src ,
14
14
interactiveScript , currentlyAddingScript , mainScript , subPath ,
15
- version = '2.1.11 ' ,
15
+ version = '2.1.15 ' ,
16
16
commentRegExp = / ( \/ \* ( [ \s \S ] * ?) \* \/ | ( [ ^ : ] | ^ ) \/ \/ ( .* ) $ ) / mg,
17
17
cjsRequireRegExp = / [ ^ . ] \s * r e q u i r e \s * \( \s * [ " ' ] ( [ ^ ' " \s ] + ) [ " ' ] \s * \) / g,
18
18
jsSuffixRegExp = / \. j s $ / ,
@@ -180,7 +180,7 @@ var requirejs, require, define;
180
180
181
181
if ( typeof requirejs !== 'undefined' ) {
182
182
if ( isFunction ( requirejs ) ) {
183
- //Do not overwrite and existing requirejs instance.
183
+ //Do not overwrite an existing requirejs instance.
184
184
return ;
185
185
}
186
186
cfg = requirejs ;
@@ -232,21 +232,20 @@ var requirejs, require, define;
232
232
* @param {Array } ary the array of path segments.
233
233
*/
234
234
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 ++ ) {
237
237
part = ary [ i ] ;
238
238
if ( part === '.' ) {
239
239
ary . splice ( i , 1 ) ;
240
240
i -= 1 ;
241
241
} 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 ;
250
249
} else if ( i > 0 ) {
251
250
ary . splice ( i - 1 , 2 ) ;
252
251
i -= 2 ;
@@ -267,43 +266,37 @@ var requirejs, require, define;
267
266
*/
268
267
function normalize ( name , baseName , applyMap ) {
269
268
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 ( '/' ) ) ,
273
271
map = config . map ,
274
272
starMap = map && map [ '*' ] ;
275
273
276
274
//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 ) {
282
289
//Convert baseName to array, and lop off the last part,
283
290
//so that . matches that 'directory' and not name of the baseName's
284
291
//module. For instance, baseName of 'one/two/three', maps to
285
292
//'one/two/three.js', but we want the directory, 'one/two' for
286
293
//this normalization.
287
294
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
-
299
295
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 ) ;
306
296
}
297
+
298
+ trimDots ( name ) ;
299
+ name = name . join ( '/' ) ;
307
300
}
308
301
309
302
//Apply map config if available.
@@ -379,7 +372,13 @@ var requirejs, require, define;
379
372
//retry
380
373
pathConfig . shift ( ) ;
381
374
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
+
383
382
return true ;
384
383
}
385
384
}
@@ -445,7 +444,16 @@ var requirejs, require, define;
445
444
return normalize ( name , parentName , applyMap ) ;
446
445
} ) ;
447
446
} 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 ;
449
457
}
450
458
} else {
451
459
//A regular module.
0 commit comments