assorted minor cleanup of variables
This commit is contained in:
parent
64f5480f96
commit
46b7cc0a72
@ -465,14 +465,14 @@ class BlockScoping {
|
|||||||
var declar;
|
var declar;
|
||||||
|
|
||||||
//
|
//
|
||||||
for (var i = 0; i < declarators.length; i++) {
|
for (let i = 0; i < declarators.length; i++) {
|
||||||
declar = declarators[i];
|
declar = declarators[i];
|
||||||
extend(this.outsideLetReferences, t.getBindingIdentifiers(declar));
|
extend(this.outsideLetReferences, t.getBindingIdentifiers(declar));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
if (block.body) {
|
if (block.body) {
|
||||||
for (i = 0; i < block.body.length; i++) {
|
for (let i = 0; i < block.body.length; i++) {
|
||||||
declar = block.body[i];
|
declar = block.body[i];
|
||||||
if (isLet(declar, block)) {
|
if (isLet(declar, block)) {
|
||||||
declarators = declarators.concat(declar.declarations);
|
declarators = declarators.concat(declar.declarations);
|
||||||
@ -481,7 +481,7 @@ class BlockScoping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
for (i = 0; i < declarators.length; i++) {
|
for (let i = 0; i < declarators.length; i++) {
|
||||||
declar = declarators[i];
|
declar = declarators[i];
|
||||||
var keys = t.getBindingIdentifiers(declar);
|
var keys = t.getBindingIdentifiers(declar);
|
||||||
extend(this.letReferences, keys);
|
extend(this.letReferences, keys);
|
||||||
|
|||||||
@ -29,14 +29,11 @@ var immutabilityVisitor = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function JSXElement(node, parent, scope, file) {
|
export function JSXElement(node, parent, scope, file) {
|
||||||
if (node._ignoreConstant) return;
|
if (node._hoisted) return;
|
||||||
|
|
||||||
var state = { isImmutable: true };
|
var state = { isImmutable: true };
|
||||||
this.traverse(immutabilityVisitor, state);
|
this.traverse(immutabilityVisitor, state);
|
||||||
this.skip();
|
this.skip();
|
||||||
|
|
||||||
if (state.isImmutable) {
|
if (state.isImmutable) this.hoist();
|
||||||
this.hoist();
|
|
||||||
node._ignoreConstant = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,6 @@ var referenceVisitor = {
|
|||||||
if (bindingInfo && bindingInfo.constant) {
|
if (bindingInfo && bindingInfo.constant) {
|
||||||
state.bindings[node.name] = bindingInfo;
|
state.bindings[node.name] = bindingInfo;
|
||||||
} else {
|
} else {
|
||||||
scope.dump();
|
|
||||||
state.foundIncompatible = true;
|
state.foundIncompatible = true;
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
@ -90,6 +89,10 @@ export default class PathHoister {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
|
var node = this.path.node;
|
||||||
|
if (node._hoisted) return;
|
||||||
|
this.path._hoisted = true;
|
||||||
|
|
||||||
this.path.traverse(referenceVisitor, this);
|
this.path.traverse(referenceVisitor, this);
|
||||||
if (this.foundIncompatible) return;
|
if (this.foundIncompatible) return;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user