estree-walker
Advanced tools
Comparing version 0.5.0 to 0.5.1
# changelog | ||
## 0.5.1 | ||
* Prevent context corruption when `walk()` is called during a walk | ||
## 0.5.0 | ||
@@ -4,0 +8,0 @@ |
@@ -8,6 +8,4 @@ function walk ( ast, ref) { | ||
var context = { | ||
skip: function () { return context.shouldSkip = true; }, | ||
shouldSkip: false | ||
}; | ||
var shouldSkip = false; | ||
var context = { skip: function () { return shouldSkip = true; } }; | ||
@@ -26,5 +24,9 @@ var childKeys = {}; | ||
if ( enter ) { | ||
context.shouldSkip = false; | ||
var _shouldSkip = shouldSkip; | ||
shouldSkip = false; | ||
enter.call( context, node, parent, prop, index ); | ||
if ( context.shouldSkip ) { return; } | ||
var skipped = shouldSkip; | ||
shouldSkip = _shouldSkip; | ||
if ( skipped ) { return; } | ||
} | ||
@@ -31,0 +33,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.estreeWalker = global.estreeWalker || {}))); | ||
(factory((global.estreeWalker = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
@@ -14,6 +14,4 @@ | ||
var context = { | ||
skip: function () { return context.shouldSkip = true; }, | ||
shouldSkip: false | ||
}; | ||
var shouldSkip = false; | ||
var context = { skip: function () { return shouldSkip = true; } }; | ||
@@ -32,5 +30,9 @@ var childKeys = {}; | ||
if ( enter ) { | ||
context.shouldSkip = false; | ||
var _shouldSkip = shouldSkip; | ||
shouldSkip = false; | ||
enter.call( context, node, parent, prop, index ); | ||
if ( context.shouldSkip ) { return; } | ||
var skipped = shouldSkip; | ||
shouldSkip = _shouldSkip; | ||
if ( skipped ) { return; } | ||
} | ||
@@ -37,0 +39,0 @@ |
{ | ||
"name": "estree-walker", | ||
"description": "Traverse an ESTree-compliant AST", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"author": "Rich Harris", | ||
@@ -24,5 +24,5 @@ "license": "MIT", | ||
"buble": "^0.15.2", | ||
"eslint": "^3.16.0", | ||
"mocha": "^3.2.0", | ||
"rollup": "^0.41.4", | ||
"eslint": "^4.5.0", | ||
"mocha": "^3.5.0", | ||
"rollup": "^0.48.0", | ||
"rollup-plugin-buble": "^0.15.0" | ||
@@ -29,0 +29,0 @@ }, |
@@ -5,6 +5,4 @@ export function walk ( ast, { enter, leave }) { | ||
const context = { | ||
skip: () => context.shouldSkip = true, | ||
shouldSkip: false | ||
}; | ||
let shouldSkip = false; | ||
const context = { skip: () => shouldSkip = true }; | ||
@@ -23,5 +21,9 @@ export const childKeys = {}; | ||
if ( enter ) { | ||
context.shouldSkip = false; | ||
let _shouldSkip = shouldSkip; | ||
shouldSkip = false; | ||
enter.call( context, node, parent, prop, index ); | ||
if ( context.shouldSkip ) return; | ||
const skipped = shouldSkip; | ||
shouldSkip = _shouldSkip; | ||
if ( skipped ) return; | ||
} | ||
@@ -28,0 +30,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
13041
133