fix bug where templates were getting polluted with old traversal paths
This commit is contained in:
parent
3cffe47eea
commit
ea1b85bffa
@ -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,
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user