use ast-types instead of using a template
This commit is contained in:
@@ -47,11 +47,15 @@ exports.ObjectExpression = function (node, parent, file) {
|
||||
containerCallee._aliasFunction = "arrows";
|
||||
|
||||
_.each(computed, function (prop) {
|
||||
containerBody.unshift(util.template("obj-key-set", {
|
||||
OBJECT_KEY: objId,
|
||||
KEY: prop.key,
|
||||
VALUE: prop.value
|
||||
}, true));
|
||||
containerBody.unshift(
|
||||
b.expressionStatement(
|
||||
b.assignmentExpression(
|
||||
"=",
|
||||
b.memberExpression(objId, prop.key, true),
|
||||
prop.value
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
return container;
|
||||
|
||||
@@ -49,14 +49,13 @@ var pushArrayPattern = function (kind, nodes, pattern, parentId) {
|
||||
|
||||
var pushPattern = function (kind, nodes, pattern, parentId, file) {
|
||||
if (parentId.type !== "MemberExpression" && parentId.type !== "Identifier") {
|
||||
var key = file.generateUid("ref");
|
||||
var key = b.identifier(file.generateUid("ref"));
|
||||
|
||||
nodes.push(util.template("variable-assign", {
|
||||
KEY: key,
|
||||
VALUE: parentId
|
||||
}, true));
|
||||
nodes.push(b.variableDeclaration("var", [
|
||||
b.variableDeclarator(key, parentId)
|
||||
]));
|
||||
|
||||
parentId = b.identifier(key);
|
||||
parentId = key;
|
||||
}
|
||||
|
||||
push(kind, nodes, pattern, parentId);
|
||||
|
||||
Reference in New Issue
Block a user