removal.js (babel-7.12.6) | : | removal.js (babel-7.12.7) | ||
---|---|---|---|---|
// This file contains methods responsible for removing a node. | // This file contains methods responsible for removing a node. | |||
import { hooks } from "./lib/removal-hooks"; | import { hooks } from "./lib/removal-hooks"; | |||
import { path as pathCache } from "../cache"; | ||||
import { REMOVED, SHOULD_SKIP } from "./index"; | import { REMOVED, SHOULD_SKIP } from "./index"; | |||
export function remove() { | export function remove() { | |||
this._assertUnremoved(); | this._assertUnremoved(); | |||
this.resync(); | this.resync(); | |||
if (!this.opts?.noScope) { | if (!this.opts?.noScope) { | |||
this._removeFromScope(); | this._removeFromScope(); | |||
} | } | |||
skipping to change at line 47 | skipping to change at line 48 | |||
this.container.splice(this.key, 1); | this.container.splice(this.key, 1); | |||
this.updateSiblingKeys(this.key, -1); | this.updateSiblingKeys(this.key, -1); | |||
} else { | } else { | |||
this._replaceWith(null); | this._replaceWith(null); | |||
} | } | |||
} | } | |||
export function _markRemoved() { | export function _markRemoved() { | |||
// this.shouldSkip = true; this.removed = true; | // this.shouldSkip = true; this.removed = true; | |||
this._traverseFlags |= SHOULD_SKIP | REMOVED; | this._traverseFlags |= SHOULD_SKIP | REMOVED; | |||
if (this.parent) pathCache.get(this.parent).delete(this.node); | ||||
this.node = null; | this.node = null; | |||
} | } | |||
export function _assertUnremoved() { | export function _assertUnremoved() { | |||
if (this.removed) { | if (this.removed) { | |||
throw this.buildCodeFrameError( | throw this.buildCodeFrameError( | |||
"NodePath has been removed so is read-only.", | "NodePath has been removed so is read-only.", | |||
); | ); | |||
} | } | |||
} | } | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 2 lines changed or added |