.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / postcss-selector-parser / dist / selectors / node.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
6
7 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
9 var cloneNode = function cloneNode(obj, parent) {
10     if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
11         return obj;
12     }
13
14     var cloned = new obj.constructor();
15
16     for (var i in obj) {
17         if (!obj.hasOwnProperty(i)) {
18             continue;
19         }
20         var value = obj[i];
21         var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
22
23         if (i === 'parent' && type === 'object') {
24             if (parent) {
25                 cloned[i] = parent;
26             }
27         } else if (value instanceof Array) {
28             cloned[i] = value.map(function (j) {
29                 return cloneNode(j, cloned);
30             });
31         } else {
32             cloned[i] = cloneNode(value, cloned);
33         }
34     }
35
36     return cloned;
37 };
38
39 var _class = function () {
40     function _class() {
41         var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
42
43         _classCallCheck(this, _class);
44
45         Object.assign(this, opts);
46         this.spaces = this.spaces || {};
47         this.spaces.before = this.spaces.before || '';
48         this.spaces.after = this.spaces.after || '';
49     }
50
51     _class.prototype.remove = function remove() {
52         if (this.parent) {
53             this.parent.removeChild(this);
54         }
55         this.parent = undefined;
56         return this;
57     };
58
59     _class.prototype.replaceWith = function replaceWith() {
60         if (this.parent) {
61             for (var index in arguments) {
62                 this.parent.insertBefore(this, arguments[index]);
63             }
64             this.remove();
65         }
66         return this;
67     };
68
69     _class.prototype.next = function next() {
70         return this.parent.at(this.parent.index(this) + 1);
71     };
72
73     _class.prototype.prev = function prev() {
74         return this.parent.at(this.parent.index(this) - 1);
75     };
76
77     _class.prototype.clone = function clone() {
78         var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
79
80         var cloned = cloneNode(this);
81         for (var name in overrides) {
82             cloned[name] = overrides[name];
83         }
84         return cloned;
85     };
86
87     _class.prototype.toString = function toString() {
88         return [this.spaces.before, String(this.value), this.spaces.after].join('');
89     };
90
91     return _class;
92 }();
93
94 exports.default = _class;
95 module.exports = exports['default'];