123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- "use strict";
- exports.__esModule = true;
- exports.default = void 0;
- var _container = _interopRequireDefault(require("./container"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Root = function (_Container) {
- _inheritsLoose(Root, _Container);
- function Root(defaults) {
- var _this;
- _this = _Container.call(this, defaults) || this;
- _this.type = 'root';
- if (!_this.nodes) _this.nodes = [];
- return _this;
- }
- var _proto = Root.prototype;
- _proto.removeChild = function removeChild(child, ignore) {
- var index = this.index(child);
- if (!ignore && index === 0 && this.nodes.length > 1) {
- this.nodes[1].raws.before = this.nodes[index].raws.before;
- }
- return _Container.prototype.removeChild.call(this, child);
- };
- _proto.normalize = function normalize(child, sample, type) {
- var nodes = _Container.prototype.normalize.call(this, child);
- if (sample) {
- if (type === 'prepend') {
- if (this.nodes.length > 1) {
- sample.raws.before = this.nodes[1].raws.before;
- } else {
- delete sample.raws.before;
- }
- } else if (this.first !== sample) {
- for (var _iterator = _createForOfIteratorHelperLoose(nodes), _step; !(_step = _iterator()).done;) {
- var node = _step.value;
- node.raws.before = sample.raws.before;
- }
- }
- }
- return nodes;
- }
-
- ;
- _proto.toResult = function toResult(opts) {
- if (opts === void 0) {
- opts = {};
- }
- var LazyResult = require('./lazy-result');
- var Processor = require('./processor');
- var lazy = new LazyResult(new Processor(), this, opts);
- return lazy.stringify();
- }
-
- ;
- return Root;
- }(_container.default);
- var _default = Root;
- exports.default = _default;
- module.exports = exports.default;
|