Skip to content

Commit 71b4ee1

Browse files
committed
snapshot
1 parent 90ff54a commit 71b4ee1

File tree

1 file changed

+50
-31
lines changed

1 file changed

+50
-31
lines changed

dist/r.js

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 2.1.13+ Wed, 28 May 2014 22:10:41 GMT Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 2.1.13+ Sun, 01 Jun 2014 23:04:13 GMT 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
*/
@@ -20,7 +20,7 @@ var requirejs, require, define, xpcUtil;
2020
(function (console, args, readFileFunc) {
2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
23-
version = '2.1.13+ Wed, 28 May 2014 22:10:41 GMT',
23+
version = '2.1.13+ Sun, 01 Jun 2014 23:04:13 GMT',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
2626
useLibLoaded = {},
@@ -22763,7 +22763,11 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2276322763

2276422764
//This string is saved off because JSLint complains
2276522765
//about obj.arguments use, as 'reserved word'
22766-
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;
2276722771

2276822772
//From an esprima example for traversing its ast.
2276922773
function traverse(object, visitor) {
@@ -22865,7 +22869,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2286522869
needsDefine = true,
2286622870
astRoot = esprima.parse(fileContents);
2286722871

22868-
parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier) {
22872+
parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier, fnExpScope) {
2286922873
if (!deps) {
2287022874
deps = [];
2287122875
}
@@ -22885,7 +22889,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2288522889
});
2288622890
}
2288722891

22888-
if (factoryIdentifier) {
22892+
if (callName === 'define' && factoryIdentifier && hasProp(fnExpScope, factoryIdentifier)) {
2288922893
return factoryIdentifier;
2289022894
}
2289122895

@@ -22938,14 +22942,18 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2293822942
* @param {Function} onMatch function to call on a parse match.
2293922943
* @param {Object} [options] This is normally the build config options if
2294022944
* it is passed.
22945+
* @param {Object} [fnExpScope] holds list of function expresssion
22946+
* argument identifiers, set up internally, not passed in
2294122947
*/
22942-
parse.recurse = function (object, onMatch, options) {
22948+
parse.recurse = function (object, onMatch, options, fnExpScope) {
2294322949
//Like traverse, but skips if branches that would not be processed
2294422950
//after has application that results in tests of true or false boolean
2294522951
//literal values.
22946-
var key, child, result,
22952+
var key, child, result, i, params, param,
2294722953
hasHas = options && options.has;
2294822954

22955+
fnExpScope = fnExpScope || emptyScope;
22956+
2294922957
if (!object) {
2295022958
return;
2295122959
}
@@ -22956,24 +22964,44 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2295622964
object.test.type === 'Literal') {
2295722965
if (object.test.value) {
2295822966
//Take the if branch
22959-
this.recurse(object.consequent, onMatch, options);
22967+
this.recurse(object.consequent, onMatch, options, fnExpScope);
2296022968
} else {
2296122969
//Take the else branch
22962-
this.recurse(object.alternate, onMatch, options);
22970+
this.recurse(object.alternate, onMatch, options, fnExpScope);
2296322971
}
2296422972
} else {
22965-
result = this.parseNode(object, onMatch);
22973+
result = this.parseNode(object, onMatch, fnExpScope);
2296622974
if (result === false) {
2296722975
return;
2296822976
} else if (typeof result === 'string') {
2296922977
return result;
2297022978
}
2297122979

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+
2297223000
for (key in object) {
2297323001
if (object.hasOwnProperty(key)) {
2297423002
child = object[key];
2297523003
if (typeof child === 'object' && child !== null) {
22976-
result = this.recurse(child, onMatch, options);
23004+
result = this.recurse(child, onMatch, options, fnExpScope);
2297723005
if (typeof result === 'string') {
2297823006
break;
2297923007
}
@@ -22985,23 +23013,10 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2298523013
//passed in as a function expression, indicating a UMD-type of
2298623014
//wrapping.
2298723015
if (typeof result === 'string') {
22988-
if (object.type === 'ExpressionStatement' && object.expression &&
22989-
object.expression.type === 'CallExpression' && object.expression.callee &&
22990-
object.expression.callee.type === 'FunctionExpression') {
22991-
object = object.expression.callee;
22992-
22993-
if (object.params && object.params.length) {
22994-
if (object.params.some(function(param) {
22995-
//Found an identifier match, so stop parsing from this
22996-
//level down.
22997-
return param.type === 'Identifier' &&
22998-
param.name === result;
22999-
})) {
23000-
//Just a plain return, parsing can continue past this
23001-
//point.
23002-
return;
23003-
}
23004-
}
23016+
if (hasProp(fnExpScope, result)) {
23017+
//Just a plain return, parsing can continue past this
23018+
//point.
23019+
return;
2300523020
}
2300623021

2300723022
return result;
@@ -23479,11 +23494,14 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2347923494
* @param {Function} onMatch a function to call when a match is found.
2348023495
* It is passed the match name, and the config, name, deps possible args.
2348123496
* 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.
2348223500
*
2348323501
* @returns {String} a JS source string with the valid require/define call.
2348423502
* Otherwise null.
2348523503
*/
23486-
parse.parseNode = function (node, onMatch) {
23504+
parse.parseNode = function (node, onMatch, fnExpScope) {
2348723505
var name, deps, cjsDeps, arg, factory, exp, refsDefine, bodyNode,
2348823506
args = node && node[argPropName],
2348923507
callName = parse.hasRequire(node);
@@ -23557,7 +23575,8 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2355723575
}
2355823576

2355923577
return onMatch("define", null, name, deps, node,
23560-
(factory && factory.type === 'Identifier' ? factory.name : undefined));
23578+
(factory && factory.type === 'Identifier' ? factory.name : undefined),
23579+
fnExpScope);
2356123580
} else if (node.type === 'CallExpression' && node.callee &&
2356223581
node.callee.type === 'FunctionExpression' &&
2356323582
node.callee.body && node.callee.body.body &&
@@ -23585,7 +23604,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2358523604

2358623605
if (refsDefine) {
2358723606
return onMatch("define", null, null, null, exp.expression,
23588-
exp.expression.arguments[0].name);
23607+
exp.expression.arguments[0].name, fnExpScope);
2358923608
}
2359023609
}
2359123610
}

0 commit comments

Comments
 (0)