add noScope option to traverse.clearProperties - fixes #624
This commit is contained in:
parent
979ce93499
commit
973be9ad96
@ -110,7 +110,7 @@ TraversalContext.prototype.visitNode = function (obj, key, opts, scope, parent,
|
|||||||
|
|
||||||
var ourScope = scope;
|
var ourScope = scope;
|
||||||
// we're entering a new scope so let's construct it!
|
// we're entering a new scope so let's construct it!
|
||||||
if (t.isScope(node)) {
|
if (!opts.noScope && t.isScope(node)) {
|
||||||
ourScope = new Scope(node, parent, scope);
|
ourScope = new Scope(node, parent, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ function traverseNode(node, opts, scope, state) {
|
|||||||
function traverse(parent, opts, scope, state) {
|
function traverse(parent, opts, scope, state) {
|
||||||
if (!parent) return;
|
if (!parent) return;
|
||||||
|
|
||||||
if (!scope) {
|
if (!opts.noScope && !scope) {
|
||||||
if (parent.type !== "Program" && parent.type !== "File") {
|
if (parent.type !== "Program" && parent.type !== "File") {
|
||||||
throw new Error("Must pass a scope unless traversing a Program/File got a " + parent.type + " node");
|
throw new Error("Must pass a scope unless traversing a Program/File got a " + parent.type + " node");
|
||||||
}
|
}
|
||||||
@ -217,7 +217,10 @@ function clearNode(node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var clearVisitor = { enter: clearNode };
|
var clearVisitor = {
|
||||||
|
noScope: true,
|
||||||
|
enter: clearNode
|
||||||
|
};
|
||||||
|
|
||||||
function clearComments(comments) {
|
function clearComments(comments) {
|
||||||
for (var i = 0; i < comments.length; i++) {
|
for (var i = 0; i < comments.length; i++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user