source: frontend/node_modules/@babel/traverse/lib/path/removal.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports._assertUnremoved = _assertUnremoved;
7exports._callRemovalHooks = _callRemovalHooks;
8exports._markRemoved = _markRemoved;
9exports._remove = _remove;
10exports._removeFromScope = _removeFromScope;
11exports.remove = remove;
12var _removalHooks = require("./lib/removal-hooks.js");
13var _cache = require("../cache.js");
14var _replacement = require("./replacement.js");
15var _index = require("./index.js");
16var t = require("@babel/types");
17var _modification = require("./modification.js");
18var _context = require("./context.js");
19function remove() {
20 var _this$opts;
21 _assertUnremoved.call(this);
22 _context.resync.call(this);
23 if (_callRemovalHooks.call(this)) {
24 _markRemoved.call(this);
25 return;
26 }
27 if (!((_this$opts = this.opts) != null && _this$opts.noScope)) {
28 _removeFromScope.call(this);
29 }
30 this.shareCommentsWithSiblings();
31 _remove.call(this);
32 _markRemoved.call(this);
33}
34function _removeFromScope() {
35 const bindings = t.getBindingIdentifiers(this.node, false, false, true);
36 Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
37}
38function _callRemovalHooks() {
39 if (this.parentPath) {
40 for (const fn of _removalHooks.hooks) {
41 if (fn(this, this.parentPath)) return true;
42 }
43 }
44}
45function _remove() {
46 if (Array.isArray(this.container)) {
47 this.container.splice(this.key, 1);
48 _modification.updateSiblingKeys.call(this, this.key, -1);
49 } else {
50 _replacement._replaceWith.call(this, null);
51 }
52}
53function _markRemoved() {
54 this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
55 if (this.parent) {
56 var _getCachedPaths;
57 (_getCachedPaths = (0, _cache.getCachedPaths)(this)) == null || _getCachedPaths.delete(this.node);
58 }
59 this.node = null;
60}
61function _assertUnremoved() {
62 if (this.removed) {
63 throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
64 }
65}
66
67//# sourceMappingURL=removal.js.map
Note: See TracBrowser for help on using the repository browser.