register variable declarator in scope when pushing
This commit is contained in:
parent
2c8437ae92
commit
be2dfaf081
@ -228,14 +228,16 @@ export default class TraversalPath {
|
||||
paths.push(TraversalPath.get(this, null, node, this.container, to));
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
_containerInsertBefore(nodes) {
|
||||
this._containerInsert(this.key, nodes);
|
||||
return this._containerInsert(this.key, nodes);
|
||||
}
|
||||
|
||||
_containerInsertAfter(nodes) {
|
||||
this._containerInsert(this.key + 1, nodes);
|
||||
return this._containerInsert(this.key + 1, nodes);
|
||||
}
|
||||
|
||||
_maybePopFromStatements(nodes) {
|
||||
|
||||
@ -631,13 +631,14 @@ export default class Scope {
|
||||
var declar = !unique && path.getData(dataKey);
|
||||
|
||||
if (!declar) {
|
||||
declar = t.variableDeclaration(opts.kind || "var", []);
|
||||
declar = t.variableDeclaration(kind, []);
|
||||
declar._generated = true;
|
||||
declar._blockHoist = 2;
|
||||
|
||||
this.file.attachAuxiliaryComment(declar);
|
||||
|
||||
path.get("body")[0]._containerInsertBefore([declar]);
|
||||
var [declarPath] = path.get("body")[0]._containerInsertBefore([declar]);
|
||||
this.registerBinding(kind, declarPath);
|
||||
if (!unique) path.setData(dataKey, declar);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user