Commit cb697fb2 authored by aniket-engg's avatar aniket-engg Committed by Aniket

astwalker improved

parent d92d3078
...@@ -21,7 +21,8 @@ AstWalker.prototype.walk = function (ast, callback) { ...@@ -21,7 +21,8 @@ AstWalker.prototype.walk = function (ast, callback) {
if (!('*' in callback)) { if (!('*' in callback)) {
callback['*'] = function () { return true } callback['*'] = function () { return true }
} }
const nodes = ast.nodes || (ast.body && ast.body.statements) || ast.declarations if(ast){
const nodes = ast.nodes || (ast.body && ast.body.statements) || ast.declarations || []
if(ast.body && ast.initializationExpression) // 'for' loop handling if(ast.body && ast.initializationExpression) // 'for' loop handling
nodes.push(ast.initializationExpression) nodes.push(ast.initializationExpression)
if (manageCallBack(ast, callback) && nodes && nodes.length > 0) { if (manageCallBack(ast, callback) && nodes && nodes.length > 0) {
...@@ -30,6 +31,7 @@ AstWalker.prototype.walk = function (ast, callback) { ...@@ -30,6 +31,7 @@ AstWalker.prototype.walk = function (ast, callback) {
this.walk(child, callback) this.walk(child, callback)
} }
} }
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment