remove noop traversal visitors methods

This commit is contained in:
Sebastian McKenzie 2015-05-09 16:52:57 +01:00
parent 2a5cb9d21b
commit f657598c72
2 changed files with 4 additions and 9 deletions

View File

@ -745,11 +745,10 @@ export default class TraversalPath {
if (!node) return;
var opts = this.opts;
var fns = [].concat(opts[key]);
if (!opts[key] && !opts[node.type]) return;
if (opts[node.type]) {
fns = fns.concat(opts[node.type][key]);
}
var fns = [].concat(opts[key]);
if (opts[node.type]) fns = fns.concat(opts[node.type][key]);
for (var fn of (fns: Array)) {
if (!fn) continue;
@ -789,7 +788,7 @@ export default class TraversalPath {
visit(): boolean {
if (this.isBlacklisted()) return false;
if (this.opts.shouldSkip(this)) return false;
if (this.opts.shouldSkip && this.opts.shouldSkip(this)) return false;
this.call("enter");

View File

@ -82,10 +82,6 @@ export function verify(visitor) {
throw new Error(messages.get("traverseVerifyRootFunction"));
}
if (!visitor.enter) visitor.enter = function () { };
if (!visitor.exit) visitor.exit = function () { };
if (!visitor.shouldSkip) visitor.shouldSkip = function () { return false; };
for (var nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;