estraverse
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -542,4 +542,5 @@ /* | ||
Controller.prototype.replace = function replace(root, visitor) { | ||
function removeElem() { | ||
function removeElem(element) { | ||
var i, | ||
key, | ||
nextElem, | ||
@@ -549,11 +550,16 @@ parent; | ||
if (element.ref.remove()) { | ||
// When the reference is an element of an array. | ||
key = element.ref.key; | ||
parent = element.ref.parent; | ||
// if removed from array, then shift following items' keys | ||
for (i = 1; i < worklist.length; i++) { | ||
// If removed from array, then decrease following items' keys. | ||
i = worklist.length; | ||
while (i--) { | ||
nextElem = worklist[i]; | ||
if (nextElem === sentinel || nextElem.ref.parent !== parent) { | ||
break; | ||
if (nextElem.ref && nextElem.ref.parent === parent) { | ||
if (nextElem.ref.key < key) { | ||
break; | ||
} | ||
--nextElem.ref.key; | ||
} | ||
nextElem.path[nextElem.path.length - 1] = --nextElem.ref.key; | ||
} | ||
@@ -609,3 +615,3 @@ } | ||
if (this.__state === REMOVE || target === REMOVE) { | ||
removeElem(); | ||
removeElem(element); | ||
} | ||
@@ -630,3 +636,3 @@ | ||
if (this.__state === REMOVE || target === REMOVE) { | ||
removeElem(); | ||
removeElem(element); | ||
element.node = null; | ||
@@ -820,3 +826,3 @@ } | ||
exports.version = '1.5.1-dev'; | ||
exports.version = '1.7.1'; | ||
exports.Syntax = Syntax; | ||
@@ -823,0 +829,0 @@ exports.traverse = traverse; |
@@ -6,3 +6,3 @@ { | ||
"main": "estraverse.js", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"engines": { | ||
@@ -9,0 +9,0 @@ "node": ">=0.10.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33752
717
5