support for CallExpression in Scope.prototype.generateUidBasedOnNode
This commit is contained in:
@@ -63,38 +63,29 @@ Scope.prototype.generateUidBasedOnNode = function (parent, file) {
|
||||
node = parent.left;
|
||||
} else if (t.isVariableDeclarator(parent)) {
|
||||
node = parent.id;
|
||||
}
|
||||
|
||||
var id = "ref";
|
||||
|
||||
if (t.isProperty(node)) {
|
||||
} else if (t.isProperty(node)) {
|
||||
node = node.key;
|
||||
}
|
||||
|
||||
if (t.isIdentifier(node)) {
|
||||
id = node.name;
|
||||
} else if (t.isLiteral(node)) {
|
||||
id = node.value;
|
||||
} else if (t.isMemberExpression(node)) {
|
||||
var parts = [];
|
||||
var parts = [];
|
||||
|
||||
var add = function (node) {
|
||||
if (t.isMemberExpression(node)) {
|
||||
add(node.object);
|
||||
add(node.property);
|
||||
} else if (t.isIdentifier(node)) {
|
||||
parts.push(node.name);
|
||||
} else if (t.isLiteral(node)) {
|
||||
parts.push(node.value);
|
||||
}
|
||||
};
|
||||
var add = function (node) {
|
||||
if (t.isMemberExpression(node)) {
|
||||
add(node.object);
|
||||
add(node.property);
|
||||
} else if (t.isIdentifier(node)) {
|
||||
parts.push(node.name);
|
||||
} else if (t.isLiteral(node)) {
|
||||
parts.push(node.value);
|
||||
} else if (t.isCallExpression(node)) {
|
||||
add(node.callee);
|
||||
}
|
||||
};
|
||||
|
||||
add(node);
|
||||
add(node);
|
||||
|
||||
id = parts.join("$");
|
||||
}
|
||||
|
||||
id = id.replace(/^_/, "");
|
||||
var id = parts.join("$");
|
||||
id = id.replace(/^_/, "") || "ref";
|
||||
|
||||
return file.generateUidIdentifier(id, this);
|
||||
};
|
||||
@@ -108,10 +99,6 @@ Scope.prototype.generateUidBasedOnNode = function (parent, file) {
|
||||
*/
|
||||
|
||||
Scope.prototype.generateTempBasedOnNode = function (node, file) {
|
||||
if (!t.isIdentifier(node) && !t.isMemberExpression(node)) {
|
||||
throw new TypeError("Invalid node type " + JSON.stringify(node.type) + " passed to Scope.prototype.generateTempBasedOnNode");
|
||||
}
|
||||
|
||||
if (t.isIdentifier(node) && this.has(node.name, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ var Test = (function () {
|
||||
_Foo.prototype.test.call(this);
|
||||
foob(_Foo);
|
||||
|
||||
_Foo.call.apply(null, [this].concat(_slice.call(arguments)));
|
||||
_Foo.call.apply(null, [this, "test"].concat(_slice.call(arguments)));
|
||||
_Foo.call.apply(_Foo, [this].concat(_slice.call(arguments)));
|
||||
_Foo.call.apply(_Foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
|
||||
(_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments)));
|
||||
(_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments)));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var _foo, _foo$bar, _foo2;
|
||||
var _foo, _foo$bar, _foo$bar2;
|
||||
var _defaults = function (obj, defaults) {
|
||||
for (var key in defaults) {
|
||||
if (obj[key] === undefined) {
|
||||
@@ -15,4 +15,4 @@ console.log((_foo = foo, _defaults(_foo, bar), _foo));
|
||||
|
||||
console.log((_foo$bar = foo[bar], _defaults(_foo$bar, bar), _foo$bar));
|
||||
|
||||
console.log((_foo2 = foo[bar()], _defaults(_foo2, bar), _foo2));
|
||||
console.log((_foo$bar2 = foo[bar()], _defaults(_foo$bar2, bar), _foo$bar2));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var _obj2, _obj4, _ref2, _obj6, _ref4;
|
||||
var _obj2, _obj4, _x2, _obj$y2, _x4;
|
||||
var _hasOwn = Object.prototype.hasOwnProperty;
|
||||
var obj = {};
|
||||
|
||||
@@ -11,17 +11,17 @@ if (!_hasOwn.call(_obj, "x")) _obj.x = 2;
|
||||
console.log((_obj2 = obj, !_hasOwn.call(_obj2, "x") && (_obj2.x = 2), _obj2.x));
|
||||
|
||||
var _obj3 = obj;
|
||||
var _ref = x();
|
||||
var _x = x();
|
||||
|
||||
if (!_hasOwn.call(_obj3, _ref)) _obj3[_ref] = 2;
|
||||
if (!_hasOwn.call(_obj3, _x)) _obj3[_x] = 2;
|
||||
|
||||
|
||||
console.log((_obj4 = obj, _ref2 = x(), !_hasOwn.call(_obj4, _ref2) && (_obj4[_ref2] = 2), _obj4[_ref2]));
|
||||
console.log((_obj4 = obj, _x2 = x(), !_hasOwn.call(_obj4, _x2) && (_obj4[_x2] = 2), _obj4[_x2]));
|
||||
|
||||
var _obj5 = obj[y()];
|
||||
var _ref3 = x();
|
||||
var _obj$y = obj[y()];
|
||||
var _x3 = x();
|
||||
|
||||
if (!_hasOwn.call(_obj5, _ref3)) _obj5[_ref3] = 2;
|
||||
if (!_hasOwn.call(_obj$y, _x3)) _obj$y[_x3] = 2;
|
||||
|
||||
|
||||
console.log((_obj6 = obj[y()], _ref4 = x(), !_hasOwn.call(_obj6, _ref4) && (_obj6[_ref4] = 2), _obj6[_ref4]));
|
||||
console.log((_obj$y2 = obj[y()], _x4 = x(), !_hasOwn.call(_obj$y2, _x4) && (_obj$y2[_x4] = 2), _obj$y2[_x4]));
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var _obj, _obj2, _obj$foo, _obj$foo2, _obj3, _args, _args2, _args3;
|
||||
var _obj, _obj2, _obj$foo, _obj$foo2, _obj$foo3, _args, _args2, _args3;
|
||||
var fn = (_obj = obj, _obj.method.bind(_obj));
|
||||
var fn = (_obj2 = obj, _obj2.method.bind(_obj2, "foob"));
|
||||
var fn = (_obj$foo = obj[foo], _obj$foo.method.bind(_obj$foo));
|
||||
var fn = (_obj$foo2 = obj.foo, _obj$foo2.method.bind(_obj$foo2));
|
||||
var fn = (_obj3 = obj[foo()], _obj3.method.bind(_obj3));
|
||||
var fn = (_obj$foo3 = obj[foo()], _obj$foo3.method.bind(_obj$foo3));
|
||||
|
||||
["foo", "bar"].map((_args = [], function (_val) {
|
||||
return _val.toUpperCase();
|
||||
|
||||
Reference in New Issue
Block a user