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";
|
import t from "../types";
|
||||||
|
|
||||||
export default class TraversalPath {
|
export default class TraversalPath {
|
||||||
constructor(parentPath, parent, container) {
|
constructor(parent, container) {
|
||||||
this.parentPath = parentPath;
|
this.container = container;
|
||||||
this.container = container;
|
this.parent = parent;
|
||||||
this.parent = parent;
|
this.data = {};
|
||||||
this.data = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get(parentPath, context, parent, container, key) {
|
static get(parentPath, context, parent, container, key) {
|
||||||
@ -25,11 +24,11 @@ export default class TraversalPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
path = new TraversalPath(parentPath, parent, container);
|
path = new TraversalPath(parent, container);
|
||||||
paths.push(path);
|
paths.push(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
path.setContext(context, key);
|
path.setContext(parentPath, context, key);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@ -57,15 +56,16 @@ export default class TraversalPath {
|
|||||||
this.scope = TraversalPath.getScope(this.node, this.parent, this.context.scope);
|
this.scope = TraversalPath.getScope(this.node, this.parent, this.context.scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
setContext(context, key) {
|
setContext(parentPath, context, key) {
|
||||||
this.shouldRemove = false;
|
this.shouldRemove = false;
|
||||||
this.shouldSkip = false;
|
this.shouldSkip = false;
|
||||||
this.shouldStop = false;
|
this.shouldStop = false;
|
||||||
|
|
||||||
this.context = context;
|
this.parentPath = parentPath;
|
||||||
this.state = context.state;
|
this.context = context;
|
||||||
this.opts = context.opts;
|
this.state = context.state;
|
||||||
this.key = key;
|
this.opts = context.opts;
|
||||||
|
this.key = key;
|
||||||
|
|
||||||
this.setScope();
|
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