Sha256: 16ae0e16e8a947ec048f2bcfcf13c51b75cf2558e1a21d4aa02a588e8479463e

Contents?: true

Size: 1.38 KB

Versions: 24

Compression:

Stored size: 1.38 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.remove = remove;
exports._removeFromScope = _removeFromScope;
exports._callRemovalHooks = _callRemovalHooks;
exports._remove = _remove;
exports._markRemoved = _markRemoved;
exports._assertUnremoved = _assertUnremoved;

var _removalHooks = require("./lib/removal-hooks");

var _index = require("./index");

function remove() {
  this._assertUnremoved();

  this.resync();

  if (!this.opts || !this.opts.noScope) {
    this._removeFromScope();
  }

  if (this._callRemovalHooks()) {
    this._markRemoved();

    return;
  }

  this.shareCommentsWithSiblings();

  this._remove();

  this._markRemoved();
}

function _removeFromScope() {
  const bindings = this.getBindingIdentifiers();
  Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
}

function _callRemovalHooks() {
  for (const fn of _removalHooks.hooks) {
    if (fn(this, this.parentPath)) return true;
  }
}

function _remove() {
  if (Array.isArray(this.container)) {
    this.container.splice(this.key, 1);
    this.updateSiblingKeys(this.key, -1);
  } else {
    this._replaceWith(null);
  }
}

function _markRemoved() {
  this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
  this.node = null;
}

function _assertUnremoved() {
  if (this.removed) {
    throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
  }
}

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
trusty-cms-5.0.7 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-5.0.6 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-5.0.5 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-5.0.4 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-5.0.3 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-5.0.2 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-5.0.1 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.3.5 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-5.0.0 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.3.4 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.3.3 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.3.2 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.3.1 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.3 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.2.3 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.2.2 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.2.1 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.2 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.1.9 node_modules/@babel/traverse/lib/path/removal.js
trusty-cms-4.1.8 node_modules/@babel/traverse/lib/path/removal.js