add utility.removeClass tests and move parentPath setting to setContext - fixes #967
This commit is contained in:
parent
70cd650e10
commit
9c9af6dbbd
@ -4,11 +4,10 @@ import Scope from "./scope";
|
||||
import t from "../types";
|
||||
|
||||
export default class TraversalPath {
|
||||
constructor(parentPath, parent, container) {
|
||||
this.parentPath = parentPath;
|
||||
this.container = container;
|
||||
this.parent = parent;
|
||||
this.data = {};
|
||||
constructor(parent, container) {
|
||||
this.container = container;
|
||||
this.parent = parent;
|
||||
this.data = {};
|
||||
}
|
||||
|
||||
static get(parentPath, context, parent, container, key) {
|
||||
@ -25,11 +24,11 @@ export default class TraversalPath {
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
path = new TraversalPath(parentPath, parent, container);
|
||||
path = new TraversalPath(parent, container);
|
||||
paths.push(path);
|
||||
}
|
||||
|
||||
path.setContext(context, key);
|
||||
path.setContext(parentPath, context, key);
|
||||
|
||||
return path;
|
||||
}
|
||||
@ -57,15 +56,16 @@ export default class TraversalPath {
|
||||
this.scope = TraversalPath.getScope(this.node, this.parent, this.context.scope);
|
||||
}
|
||||
|
||||
setContext(context, key) {
|
||||
setContext(parentPath, context, key) {
|
||||
this.shouldRemove = false;
|
||||
this.shouldSkip = false;
|
||||
this.shouldStop = false;
|
||||
|
||||
this.context = context;
|
||||
this.state = context.state;
|
||||
this.opts = context.opts;
|
||||
this.key = key;
|
||||
this.parentPath = parentPath;
|
||||
this.context = context;
|
||||
this.state = context.state;
|
||||
this.opts = context.opts;
|
||||
this.key = key;
|
||||
|
||||
this.setScope();
|
||||
}
|
||||
|
||||
3
test/fixtures/transformation/utility.remove-console/nested/actual.js
vendored
Normal file
3
test/fixtures/transformation/utility.remove-console/nested/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
function foo() {
|
||||
console.log("foo");
|
||||
}
|
||||
3
test/fixtures/transformation/utility.remove-console/nested/expected.js
vendored
Normal file
3
test/fixtures/transformation/utility.remove-console/nested/expected.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {}
|
||||
3
test/fixtures/transformation/utility.remove-console/options.json
vendored
Normal file
3
test/fixtures/transformation/utility.remove-console/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"optional": ["utility.removeConsole"]
|
||||
}
|
||||
1
test/fixtures/transformation/utility.remove-console/top-level/actual.js
vendored
Normal file
1
test/fixtures/transformation/utility.remove-console/top-level/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
console.log("foo");
|
||||
1
test/fixtures/transformation/utility.remove-console/top-level/expected.js
vendored
Normal file
1
test/fixtures/transformation/utility.remove-console/top-level/expected.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
"use strict";
|
||||
Loading…
x
Reference in New Issue
Block a user