-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New replaced node should be traversed #25
Comments
Yeah, this story is pretty broken. I originally didn't want to force replacement nodes to be traversed, but that seems to be what one almost always wants. You can technically call types.traverse(
this.replace(functionExpressionNode)[0],
arguments.callee
); but that's admittedly pretty ugly. |
One case where you don't want automatic traversal is when you pass multiple arguments to types.traverse(ast, function addLogging(node) {
if (n.Statement.check(node)) {
this.replace(
makeConsoleLogStatementFor(node),
node // Don't want to traverse this node again!
);
}
}); Without some sort of additional check, automatic traversal would result in this traversal never terminating. |
It seems like having both methods would be the best then. |
Hi @benjamn just to let you know
Worked well for me, thank you! :) I was doing:
Which was making me lose all the parent context of |
👍 On Tuesday, July 8, 2014, Ben Newman notifications@github.com wrote:
Fabio Miranda Costa |
This is first of all a question, shouldn't the new nodes added by replace be traversed?
Ex:
functionExpressionNode
doesn't get traversed.The text was updated successfully, but these errors were encountered: