1
1
/**
2
- * @license r.js 2.1.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 2.1.14 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
*/
@@ -20,7 +20,7 @@ var requirejs, require, define, xpcUtil;
20
20
(function (console, args, readFileFunc) {
21
21
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
22
22
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
23
- version = '2.1.13 ',
23
+ version = '2.1.14 ',
24
24
jsSuffixRegExp = /\.js$/,
25
25
commandOption = '',
26
26
useLibLoaded = {},
@@ -238,7 +238,7 @@ var requirejs, require, define, xpcUtil;
238
238
}
239
239
240
240
/** vim: et:ts=4:sw=4:sts=4
241
- * @license RequireJS 2.1.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
241
+ * @license RequireJS 2.1.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
242
242
* Available via the MIT or new BSD license.
243
243
* see: http://github.com/jrburke/requirejs for details
244
244
*/
@@ -251,7 +251,7 @@ var requirejs, require, define, xpcUtil;
251
251
(function (global) {
252
252
var req, s, head, baseElement, dataMain, src,
253
253
interactiveScript, currentlyAddingScript, mainScript, subPath,
254
- version = '2.1.13 ',
254
+ version = '2.1.14 ',
255
255
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
256
256
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
257
257
jsSuffixRegExp = /\.js$/,
@@ -683,7 +683,16 @@ var requirejs, require, define, xpcUtil;
683
683
return normalize(name, parentName, applyMap);
684
684
});
685
685
} else {
686
- normalizedName = normalize(name, parentName, applyMap);
686
+ // If nested plugin references, then do not try to
687
+ // normalize, as it will not normalize correctly. This
688
+ // places a restriction on resourceIds, and the longer
689
+ // term solution is not to normalize until plugins are
690
+ // loaded and all normalizations to allow for async
691
+ // loading of a loader plugin. But for now, fixes the
692
+ // common uses. Details in #1131
693
+ normalizedName = name.indexOf('!') === -1 ?
694
+ normalize(name, parentName, applyMap) :
695
+ name;
687
696
}
688
697
} else {
689
698
//A regular module.
@@ -22754,7 +22763,11 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22754
22763
22755
22764
//This string is saved off because JSLint complains
22756
22765
//about obj.arguments use, as 'reserved word'
22757
- var argPropName = 'arguments';
22766
+ var argPropName = 'arguments',
22767
+ //Default object to use for "scope" checking for UMD identifiers.
22768
+ emptyScope = {},
22769
+ mixin = lang.mixin,
22770
+ hasProp = lang.hasProp;
22758
22771
22759
22772
//From an esprima example for traversing its ast.
22760
22773
function traverse(object, visitor) {
@@ -22856,7 +22869,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22856
22869
needsDefine = true,
22857
22870
astRoot = esprima.parse(fileContents);
22858
22871
22859
- parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier) {
22872
+ parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier, fnExpScope ) {
22860
22873
if (!deps) {
22861
22874
deps = [];
22862
22875
}
@@ -22876,7 +22889,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22876
22889
});
22877
22890
}
22878
22891
22879
- if (factoryIdentifier) {
22892
+ if (callName === 'define' && factoryIdentifier && hasProp(fnExpScope, factoryIdentifier) ) {
22880
22893
return factoryIdentifier;
22881
22894
}
22882
22895
@@ -22929,14 +22942,18 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22929
22942
* @param {Function} onMatch function to call on a parse match.
22930
22943
* @param {Object} [options] This is normally the build config options if
22931
22944
* it is passed.
22945
+ * @param {Object} [fnExpScope] holds list of function expresssion
22946
+ * argument identifiers, set up internally, not passed in
22932
22947
*/
22933
- parse.recurse = function (object, onMatch, options) {
22948
+ parse.recurse = function (object, onMatch, options, fnExpScope ) {
22934
22949
//Like traverse, but skips if branches that would not be processed
22935
22950
//after has application that results in tests of true or false boolean
22936
22951
//literal values.
22937
- var key, child, result,
22952
+ var key, child, result, i, params, param,
22938
22953
hasHas = options && options.has;
22939
22954
22955
+ fnExpScope = fnExpScope || emptyScope;
22956
+
22940
22957
if (!object) {
22941
22958
return;
22942
22959
}
@@ -22947,24 +22964,44 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22947
22964
object.test.type === 'Literal') {
22948
22965
if (object.test.value) {
22949
22966
//Take the if branch
22950
- this.recurse(object.consequent, onMatch, options);
22967
+ this.recurse(object.consequent, onMatch, options, fnExpScope );
22951
22968
} else {
22952
22969
//Take the else branch
22953
- this.recurse(object.alternate, onMatch, options);
22970
+ this.recurse(object.alternate, onMatch, options, fnExpScope );
22954
22971
}
22955
22972
} else {
22956
- result = this.parseNode(object, onMatch);
22973
+ result = this.parseNode(object, onMatch, fnExpScope );
22957
22974
if (result === false) {
22958
22975
return;
22959
22976
} else if (typeof result === 'string') {
22960
22977
return result;
22961
22978
}
22962
22979
22980
+ //Build up a "scope" object that informs nested recurse calls if
22981
+ //the define call references an identifier that is likely a UMD
22982
+ //wrapped function expresion argument.
22983
+ if (object.type === 'ExpressionStatement' && object.expression &&
22984
+ object.expression.type === 'CallExpression' && object.expression.callee &&
22985
+ object.expression.callee.type === 'FunctionExpression') {
22986
+ object = object.expression.callee;
22987
+
22988
+ if (object.params && object.params.length) {
22989
+ params = object.params;
22990
+ fnExpScope = mixin({}, fnExpScope, true);
22991
+ for (i = 0; i < params.length; i++) {
22992
+ param = params[i];
22993
+ if (param.type === 'Identifier') {
22994
+ fnExpScope[param.name] = true;
22995
+ }
22996
+ }
22997
+ }
22998
+ }
22999
+
22963
23000
for (key in object) {
22964
23001
if (object.hasOwnProperty(key)) {
22965
23002
child = object[key];
22966
23003
if (typeof child === 'object' && child !== null) {
22967
- result = this.recurse(child, onMatch, options);
23004
+ result = this.recurse(child, onMatch, options, fnExpScope );
22968
23005
if (typeof result === 'string') {
22969
23006
break;
22970
23007
}
@@ -22976,23 +23013,10 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22976
23013
//passed in as a function expression, indicating a UMD-type of
22977
23014
//wrapping.
22978
23015
if (typeof result === 'string') {
22979
- if (object.type === 'ExpressionStatement' && object.expression &&
22980
- object.expression.type === 'CallExpression' && object.expression.callee &&
22981
- object.expression.callee.type === 'FunctionExpression') {
22982
- object = object.expression.callee;
22983
-
22984
- if (object.params && object.params.length) {
22985
- if (object.params.some(function(param) {
22986
- //Found an identifier match, so stop parsing from this
22987
- //level down.
22988
- return param.type === 'Identifier' &&
22989
- param.name === result;
22990
- })) {
22991
- //Just a plain return, parsing can continue past this
22992
- //point.
22993
- return;
22994
- }
22995
- }
23016
+ if (hasProp(fnExpScope, result)) {
23017
+ //Just a plain return, parsing can continue past this
23018
+ //point.
23019
+ return;
22996
23020
}
22997
23021
22998
23022
return result;
@@ -23470,11 +23494,14 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
23470
23494
* @param {Function} onMatch a function to call when a match is found.
23471
23495
* It is passed the match name, and the config, name, deps possible args.
23472
23496
* The config, name and deps args are not normalized.
23497
+ * @param {Object} fnExpScope an object whose keys are all function
23498
+ * expression identifiers that should be in scope. Useful for UMD wrapper
23499
+ * detection to avoid parsing more into the wrapped UMD code.
23473
23500
*
23474
23501
* @returns {String} a JS source string with the valid require/define call.
23475
23502
* Otherwise null.
23476
23503
*/
23477
- parse.parseNode = function (node, onMatch) {
23504
+ parse.parseNode = function (node, onMatch, fnExpScope ) {
23478
23505
var name, deps, cjsDeps, arg, factory, exp, refsDefine, bodyNode,
23479
23506
args = node && node[argPropName],
23480
23507
callName = parse.hasRequire(node);
@@ -23548,7 +23575,8 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
23548
23575
}
23549
23576
23550
23577
return onMatch("define", null, name, deps, node,
23551
- (factory && factory.type === 'Identifier' ? factory.name : undefined));
23578
+ (factory && factory.type === 'Identifier' ? factory.name : undefined),
23579
+ fnExpScope);
23552
23580
} else if (node.type === 'CallExpression' && node.callee &&
23553
23581
node.callee.type === 'FunctionExpression' &&
23554
23582
node.callee.body && node.callee.body.body &&
@@ -23576,7 +23604,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
23576
23604
23577
23605
if (refsDefine) {
23578
23606
return onMatch("define", null, null, null, exp.expression,
23579
- exp.expression.arguments[0].name);
23607
+ exp.expression.arguments[0].name, fnExpScope );
23580
23608
}
23581
23609
}
23582
23610
}
@@ -25151,6 +25179,11 @@ define('requirePatch', [ 'env!env/file', 'pragma', 'parse', 'lang', 'logger', 'c
25151
25179
falseProp = lang.falseProp,
25152
25180
getOwn = lang.getOwn;
25153
25181
25182
+ //Turn off throwing on resolution conflict, that was just an older prim
25183
+ //idea about finding errors early, but does not comply with how promises
25184
+ //should operate.
25185
+ prim.hideResolutionConflict = true;
25186
+
25154
25187
//This method should be called when the patches to require should take hold.
25155
25188
return function () {
25156
25189
if (!allowRun) {
0 commit comments