fix bug where templates were getting polluted with old traversal paths

This commit is contained in:
Sebastian McKenzie 2015-06-08 01:25:51 +01:00
parent 3cffe47eea
commit ea1b85bffa
3 changed files with 9 additions and 4 deletions

View File

@ -481,7 +481,7 @@ export default class File {
}
_addAst(ast) {
this.path = NodePath.get({
this.path = NodePath.get({
hub: this.hub,
parentPath: null,
parent: ast,

View File

@ -49,7 +49,7 @@ const CLEAR_KEYS = [
"tokens", "range", "start", "end", "loc", "raw"
];
function clearNode(node) {
traverse.clearNode = function (node) {
for (var i = 0; i < CLEAR_KEYS.length; i++) {
let key = CLEAR_KEYS[i];
if (node[key] != null) node[key] = null;
@ -58,12 +58,12 @@ function clearNode(node) {
var clearVisitor = {
noScope: true,
exit: clearNode
exit: traverse.clearNode
};
traverse.removeProperties = function (tree) {
traverse(tree, clearVisitor);
clearNode(tree);
traverse.clearNode(tree);
return tree;
};

View File

@ -127,6 +127,7 @@ export function shouldIgnore(filename, ignore, only) {
var templateVisitor = {
noScope: true,
enter(node, parent, scope, nodes) {
if (t.isExpressionStatement(node)) {
node = node.expression;
@ -136,6 +137,10 @@ var templateVisitor = {
this.skip();
this.replaceInline(nodes[node.name]);
}
},
exit(node) {
traverse.clearNode(node);
}
};