container.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = void 0;
  4. var _declaration = _interopRequireDefault(require("./declaration"));
  5. var _comment = _interopRequireDefault(require("./comment"));
  6. var _node = _interopRequireDefault(require("./node"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  11. function cleanSource(nodes) {
  12. return nodes.map(function (i) {
  13. if (i.nodes) i.nodes = cleanSource(i.nodes);
  14. delete i.source;
  15. return i;
  16. });
  17. }
  18. /**
  19. * The {@link Root}, {@link AtRule}, and {@link Rule} container nodes
  20. * inherit some common methods to help work with their children.
  21. *
  22. * Note that all containers can store any content. If you write a rule inside
  23. * a rule, PostCSS will parse it.
  24. *
  25. * @extends Node
  26. * @abstract
  27. */
  28. var Container =
  29. /*#__PURE__*/
  30. function (_Node) {
  31. _inheritsLoose(Container, _Node);
  32. function Container() {
  33. return _Node.apply(this, arguments) || this;
  34. }
  35. var _proto = Container.prototype;
  36. _proto.push = function push(child) {
  37. child.parent = this;
  38. this.nodes.push(child);
  39. return this;
  40. }
  41. /**
  42. * Iterates through the container’s immediate children,
  43. * calling `callback` for each child.
  44. *
  45. * Returning `false` in the callback will break iteration.
  46. *
  47. * This method only iterates through the container’s immediate children.
  48. * If you need to recursively iterate through all the container’s descendant
  49. * nodes, use {@link Container#walk}.
  50. *
  51. * Unlike the for `{}`-cycle or `Array#forEach` this iterator is safe
  52. * if you are mutating the array of child nodes during iteration.
  53. * PostCSS will adjust the current index to match the mutations.
  54. *
  55. * @param {childIterator} callback Iterator receives each node and index.
  56. *
  57. * @return {false|undefined} Returns `false` if iteration was broke.
  58. *
  59. * @example
  60. * const root = postcss.parse('a { color: black; z-index: 1 }')
  61. * const rule = root.first
  62. *
  63. * for (const decl of rule.nodes) {
  64. * decl.cloneBefore({ prop: '-webkit-' + decl.prop })
  65. * // Cycle will be infinite, because cloneBefore moves the current node
  66. * // to the next index
  67. * }
  68. *
  69. * rule.each(decl => {
  70. * decl.cloneBefore({ prop: '-webkit-' + decl.prop })
  71. * // Will be executed only for color and z-index
  72. * })
  73. */
  74. ;
  75. _proto.each = function each(callback) {
  76. if (!this.lastEach) this.lastEach = 0;
  77. if (!this.indexes) this.indexes = {};
  78. this.lastEach += 1;
  79. var id = this.lastEach;
  80. this.indexes[id] = 0;
  81. if (!this.nodes) return undefined;
  82. var index, result;
  83. while (this.indexes[id] < this.nodes.length) {
  84. index = this.indexes[id];
  85. result = callback(this.nodes[index], index);
  86. if (result === false) break;
  87. this.indexes[id] += 1;
  88. }
  89. delete this.indexes[id];
  90. return result;
  91. }
  92. /**
  93. * Traverses the container’s descendant nodes, calling callback
  94. * for each node.
  95. *
  96. * Like container.each(), this method is safe to use
  97. * if you are mutating arrays during iteration.
  98. *
  99. * If you only need to iterate through the container’s immediate children,
  100. * use {@link Container#each}.
  101. *
  102. * @param {childIterator} callback Iterator receives each node and index.
  103. *
  104. * @return {false|undefined} Returns `false` if iteration was broke.
  105. *
  106. * @example
  107. * root.walk(node => {
  108. * // Traverses all descendant nodes.
  109. * })
  110. */
  111. ;
  112. _proto.walk = function walk(callback) {
  113. return this.each(function (child, i) {
  114. var result;
  115. try {
  116. result = callback(child, i);
  117. } catch (e) {
  118. e.postcssNode = child;
  119. if (e.stack && child.source && /\n\s{4}at /.test(e.stack)) {
  120. var s = child.source;
  121. e.stack = e.stack.replace(/\n\s{4}at /, "$&" + s.input.from + ":" + s.start.line + ":" + s.start.column + "$&");
  122. }
  123. throw e;
  124. }
  125. if (result !== false && child.walk) {
  126. result = child.walk(callback);
  127. }
  128. return result;
  129. });
  130. }
  131. /**
  132. * Traverses the container’s descendant nodes, calling callback
  133. * for each declaration node.
  134. *
  135. * If you pass a filter, iteration will only happen over declarations
  136. * with matching properties.
  137. *
  138. * Like {@link Container#each}, this method is safe
  139. * to use if you are mutating arrays during iteration.
  140. *
  141. * @param {string|RegExp} [prop] String or regular expression
  142. * to filter declarations by property name.
  143. * @param {childIterator} callback Iterator receives each node and index.
  144. *
  145. * @return {false|undefined} Returns `false` if iteration was broke.
  146. *
  147. * @example
  148. * root.walkDecls(decl => {
  149. * checkPropertySupport(decl.prop)
  150. * })
  151. *
  152. * root.walkDecls('border-radius', decl => {
  153. * decl.remove()
  154. * })
  155. *
  156. * root.walkDecls(/^background/, decl => {
  157. * decl.value = takeFirstColorFromGradient(decl.value)
  158. * })
  159. */
  160. ;
  161. _proto.walkDecls = function walkDecls(prop, callback) {
  162. if (!callback) {
  163. callback = prop;
  164. return this.walk(function (child, i) {
  165. if (child.type === 'decl') {
  166. return callback(child, i);
  167. }
  168. });
  169. }
  170. if (prop instanceof RegExp) {
  171. return this.walk(function (child, i) {
  172. if (child.type === 'decl' && prop.test(child.prop)) {
  173. return callback(child, i);
  174. }
  175. });
  176. }
  177. return this.walk(function (child, i) {
  178. if (child.type === 'decl' && child.prop === prop) {
  179. return callback(child, i);
  180. }
  181. });
  182. }
  183. /**
  184. * Traverses the container’s descendant nodes, calling callback
  185. * for each rule node.
  186. *
  187. * If you pass a filter, iteration will only happen over rules
  188. * with matching selectors.
  189. *
  190. * Like {@link Container#each}, this method is safe
  191. * to use if you are mutating arrays during iteration.
  192. *
  193. * @param {string|RegExp} [selector] String or regular expression
  194. * to filter rules by selector.
  195. * @param {childIterator} callback Iterator receives each node and index.
  196. *
  197. * @return {false|undefined} returns `false` if iteration was broke.
  198. *
  199. * @example
  200. * const selectors = []
  201. * root.walkRules(rule => {
  202. * selectors.push(rule.selector)
  203. * })
  204. * console.log(`Your CSS uses ${ selectors.length } selectors`)
  205. */
  206. ;
  207. _proto.walkRules = function walkRules(selector, callback) {
  208. if (!callback) {
  209. callback = selector;
  210. return this.walk(function (child, i) {
  211. if (child.type === 'rule') {
  212. return callback(child, i);
  213. }
  214. });
  215. }
  216. if (selector instanceof RegExp) {
  217. return this.walk(function (child, i) {
  218. if (child.type === 'rule' && selector.test(child.selector)) {
  219. return callback(child, i);
  220. }
  221. });
  222. }
  223. return this.walk(function (child, i) {
  224. if (child.type === 'rule' && child.selector === selector) {
  225. return callback(child, i);
  226. }
  227. });
  228. }
  229. /**
  230. * Traverses the container’s descendant nodes, calling callback
  231. * for each at-rule node.
  232. *
  233. * If you pass a filter, iteration will only happen over at-rules
  234. * that have matching names.
  235. *
  236. * Like {@link Container#each}, this method is safe
  237. * to use if you are mutating arrays during iteration.
  238. *
  239. * @param {string|RegExp} [name] String or regular expression
  240. * to filter at-rules by name.
  241. * @param {childIterator} callback Iterator receives each node and index.
  242. *
  243. * @return {false|undefined} Returns `false` if iteration was broke.
  244. *
  245. * @example
  246. * root.walkAtRules(rule => {
  247. * if (isOld(rule.name)) rule.remove()
  248. * })
  249. *
  250. * let first = false
  251. * root.walkAtRules('charset', rule => {
  252. * if (!first) {
  253. * first = true
  254. * } else {
  255. * rule.remove()
  256. * }
  257. * })
  258. */
  259. ;
  260. _proto.walkAtRules = function walkAtRules(name, callback) {
  261. if (!callback) {
  262. callback = name;
  263. return this.walk(function (child, i) {
  264. if (child.type === 'atrule') {
  265. return callback(child, i);
  266. }
  267. });
  268. }
  269. if (name instanceof RegExp) {
  270. return this.walk(function (child, i) {
  271. if (child.type === 'atrule' && name.test(child.name)) {
  272. return callback(child, i);
  273. }
  274. });
  275. }
  276. return this.walk(function (child, i) {
  277. if (child.type === 'atrule' && child.name === name) {
  278. return callback(child, i);
  279. }
  280. });
  281. }
  282. /**
  283. * Traverses the container’s descendant nodes, calling callback
  284. * for each comment node.
  285. *
  286. * Like {@link Container#each}, this method is safe
  287. * to use if you are mutating arrays during iteration.
  288. *
  289. * @param {childIterator} callback Iterator receives each node and index.
  290. *
  291. * @return {false|undefined} Returns `false` if iteration was broke.
  292. *
  293. * @example
  294. * root.walkComments(comment => {
  295. * comment.remove()
  296. * })
  297. */
  298. ;
  299. _proto.walkComments = function walkComments(callback) {
  300. return this.walk(function (child, i) {
  301. if (child.type === 'comment') {
  302. return callback(child, i);
  303. }
  304. });
  305. }
  306. /**
  307. * Inserts new nodes to the end of the container.
  308. *
  309. * @param {...(Node|object|string|Node[])} children New nodes.
  310. *
  311. * @return {Node} This node for methods chain.
  312. *
  313. * @example
  314. * const decl1 = postcss.decl({ prop: 'color', value: 'black' })
  315. * const decl2 = postcss.decl({ prop: 'background-color', value: 'white' })
  316. * rule.append(decl1, decl2)
  317. *
  318. * root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
  319. * root.append({ selector: 'a' }) // rule
  320. * rule.append({ prop: 'color', value: 'black' }) // declaration
  321. * rule.append({ text: 'Comment' }) // comment
  322. *
  323. * root.append('a {}')
  324. * root.first.append('color: black; z-index: 1')
  325. */
  326. ;
  327. _proto.append = function append() {
  328. for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
  329. children[_key] = arguments[_key];
  330. }
  331. for (var _i = 0; _i < children.length; _i++) {
  332. var child = children[_i];
  333. var nodes = this.normalize(child, this.last);
  334. for (var _iterator = nodes, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  335. var _ref;
  336. if (_isArray) {
  337. if (_i2 >= _iterator.length) break;
  338. _ref = _iterator[_i2++];
  339. } else {
  340. _i2 = _iterator.next();
  341. if (_i2.done) break;
  342. _ref = _i2.value;
  343. }
  344. var node = _ref;
  345. this.nodes.push(node);
  346. }
  347. }
  348. return this;
  349. }
  350. /**
  351. * Inserts new nodes to the start of the container.
  352. *
  353. * @param {...(Node|object|string|Node[])} children New nodes.
  354. *
  355. * @return {Node} This node for methods chain.
  356. *
  357. * @example
  358. * const decl1 = postcss.decl({ prop: 'color', value: 'black' })
  359. * const decl2 = postcss.decl({ prop: 'background-color', value: 'white' })
  360. * rule.prepend(decl1, decl2)
  361. *
  362. * root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
  363. * root.append({ selector: 'a' }) // rule
  364. * rule.append({ prop: 'color', value: 'black' }) // declaration
  365. * rule.append({ text: 'Comment' }) // comment
  366. *
  367. * root.append('a {}')
  368. * root.first.append('color: black; z-index: 1')
  369. */
  370. ;
  371. _proto.prepend = function prepend() {
  372. for (var _len2 = arguments.length, children = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  373. children[_key2] = arguments[_key2];
  374. }
  375. children = children.reverse();
  376. for (var _iterator2 = children, _isArray2 = Array.isArray(_iterator2), _i3 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
  377. var _ref2;
  378. if (_isArray2) {
  379. if (_i3 >= _iterator2.length) break;
  380. _ref2 = _iterator2[_i3++];
  381. } else {
  382. _i3 = _iterator2.next();
  383. if (_i3.done) break;
  384. _ref2 = _i3.value;
  385. }
  386. var child = _ref2;
  387. var nodes = this.normalize(child, this.first, 'prepend').reverse();
  388. for (var _iterator3 = nodes, _isArray3 = Array.isArray(_iterator3), _i4 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
  389. var _ref3;
  390. if (_isArray3) {
  391. if (_i4 >= _iterator3.length) break;
  392. _ref3 = _iterator3[_i4++];
  393. } else {
  394. _i4 = _iterator3.next();
  395. if (_i4.done) break;
  396. _ref3 = _i4.value;
  397. }
  398. var node = _ref3;
  399. this.nodes.unshift(node);
  400. }
  401. for (var id in this.indexes) {
  402. this.indexes[id] = this.indexes[id] + nodes.length;
  403. }
  404. }
  405. return this;
  406. };
  407. _proto.cleanRaws = function cleanRaws(keepBetween) {
  408. _Node.prototype.cleanRaws.call(this, keepBetween);
  409. if (this.nodes) {
  410. for (var _iterator4 = this.nodes, _isArray4 = Array.isArray(_iterator4), _i5 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
  411. var _ref4;
  412. if (_isArray4) {
  413. if (_i5 >= _iterator4.length) break;
  414. _ref4 = _iterator4[_i5++];
  415. } else {
  416. _i5 = _iterator4.next();
  417. if (_i5.done) break;
  418. _ref4 = _i5.value;
  419. }
  420. var node = _ref4;
  421. node.cleanRaws(keepBetween);
  422. }
  423. }
  424. }
  425. /**
  426. * Insert new node before old node within the container.
  427. *
  428. * @param {Node|number} exist Child or child’s index.
  429. * @param {Node|object|string|Node[]} add New node.
  430. *
  431. * @return {Node} This node for methods chain.
  432. *
  433. * @example
  434. * rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
  435. */
  436. ;
  437. _proto.insertBefore = function insertBefore(exist, add) {
  438. exist = this.index(exist);
  439. var type = exist === 0 ? 'prepend' : false;
  440. var nodes = this.normalize(add, this.nodes[exist], type).reverse();
  441. for (var _iterator5 = nodes, _isArray5 = Array.isArray(_iterator5), _i6 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
  442. var _ref5;
  443. if (_isArray5) {
  444. if (_i6 >= _iterator5.length) break;
  445. _ref5 = _iterator5[_i6++];
  446. } else {
  447. _i6 = _iterator5.next();
  448. if (_i6.done) break;
  449. _ref5 = _i6.value;
  450. }
  451. var node = _ref5;
  452. this.nodes.splice(exist, 0, node);
  453. }
  454. var index;
  455. for (var id in this.indexes) {
  456. index = this.indexes[id];
  457. if (exist <= index) {
  458. this.indexes[id] = index + nodes.length;
  459. }
  460. }
  461. return this;
  462. }
  463. /**
  464. * Insert new node after old node within the container.
  465. *
  466. * @param {Node|number} exist Child or child’s index.
  467. * @param {Node|object|string|Node[]} add New node.
  468. *
  469. * @return {Node} This node for methods chain.
  470. */
  471. ;
  472. _proto.insertAfter = function insertAfter(exist, add) {
  473. exist = this.index(exist);
  474. var nodes = this.normalize(add, this.nodes[exist]).reverse();
  475. for (var _iterator6 = nodes, _isArray6 = Array.isArray(_iterator6), _i7 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
  476. var _ref6;
  477. if (_isArray6) {
  478. if (_i7 >= _iterator6.length) break;
  479. _ref6 = _iterator6[_i7++];
  480. } else {
  481. _i7 = _iterator6.next();
  482. if (_i7.done) break;
  483. _ref6 = _i7.value;
  484. }
  485. var node = _ref6;
  486. this.nodes.splice(exist + 1, 0, node);
  487. }
  488. var index;
  489. for (var id in this.indexes) {
  490. index = this.indexes[id];
  491. if (exist < index) {
  492. this.indexes[id] = index + nodes.length;
  493. }
  494. }
  495. return this;
  496. }
  497. /**
  498. * Removes node from the container and cleans the parent properties
  499. * from the node and its children.
  500. *
  501. * @param {Node|number} child Child or child’s index.
  502. *
  503. * @return {Node} This node for methods chain
  504. *
  505. * @example
  506. * rule.nodes.length //=> 5
  507. * rule.removeChild(decl)
  508. * rule.nodes.length //=> 4
  509. * decl.parent //=> undefined
  510. */
  511. ;
  512. _proto.removeChild = function removeChild(child) {
  513. child = this.index(child);
  514. this.nodes[child].parent = undefined;
  515. this.nodes.splice(child, 1);
  516. var index;
  517. for (var id in this.indexes) {
  518. index = this.indexes[id];
  519. if (index >= child) {
  520. this.indexes[id] = index - 1;
  521. }
  522. }
  523. return this;
  524. }
  525. /**
  526. * Removes all children from the container
  527. * and cleans their parent properties.
  528. *
  529. * @return {Node} This node for methods chain.
  530. *
  531. * @example
  532. * rule.removeAll()
  533. * rule.nodes.length //=> 0
  534. */
  535. ;
  536. _proto.removeAll = function removeAll() {
  537. for (var _iterator7 = this.nodes, _isArray7 = Array.isArray(_iterator7), _i8 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) {
  538. var _ref7;
  539. if (_isArray7) {
  540. if (_i8 >= _iterator7.length) break;
  541. _ref7 = _iterator7[_i8++];
  542. } else {
  543. _i8 = _iterator7.next();
  544. if (_i8.done) break;
  545. _ref7 = _i8.value;
  546. }
  547. var node = _ref7;
  548. node.parent = undefined;
  549. }
  550. this.nodes = [];
  551. return this;
  552. }
  553. /**
  554. * Passes all declaration values within the container that match pattern
  555. * through callback, replacing those values with the returned result
  556. * of callback.
  557. *
  558. * This method is useful if you are using a custom unit or function
  559. * and need to iterate through all values.
  560. *
  561. * @param {string|RegExp} pattern Replace pattern.
  562. * @param {object} opts Options to speed up the search.
  563. * @param {string|string[]} opts.props An array of property names.
  564. * @param {string} opts.fast String that’s used to narrow down
  565. * values and speed up the regexp search.
  566. * @param {function|string} callback String to replace pattern or callback
  567. * that returns a new value. The callback
  568. * will receive the same arguments
  569. * as those passed to a function parameter
  570. * of `String#replace`.
  571. *
  572. * @return {Node} This node for methods chain.
  573. *
  574. * @example
  575. * root.replaceValues(/\d+rem/, { fast: 'rem' }, string => {
  576. * return 15 * parseInt(string) + 'px'
  577. * })
  578. */
  579. ;
  580. _proto.replaceValues = function replaceValues(pattern, opts, callback) {
  581. if (!callback) {
  582. callback = opts;
  583. opts = {};
  584. }
  585. this.walkDecls(function (decl) {
  586. if (opts.props && opts.props.indexOf(decl.prop) === -1) return;
  587. if (opts.fast && decl.value.indexOf(opts.fast) === -1) return;
  588. decl.value = decl.value.replace(pattern, callback);
  589. });
  590. return this;
  591. }
  592. /**
  593. * Returns `true` if callback returns `true`
  594. * for all of the container’s children.
  595. *
  596. * @param {childCondition} condition Iterator returns true or false.
  597. *
  598. * @return {boolean} Is every child pass condition.
  599. *
  600. * @example
  601. * const noPrefixes = rule.every(i => i.prop[0] !== '-')
  602. */
  603. ;
  604. _proto.every = function every(condition) {
  605. return this.nodes.every(condition);
  606. }
  607. /**
  608. * Returns `true` if callback returns `true` for (at least) one
  609. * of the container’s children.
  610. *
  611. * @param {childCondition} condition Iterator returns true or false.
  612. *
  613. * @return {boolean} Is some child pass condition.
  614. *
  615. * @example
  616. * const hasPrefix = rule.some(i => i.prop[0] === '-')
  617. */
  618. ;
  619. _proto.some = function some(condition) {
  620. return this.nodes.some(condition);
  621. }
  622. /**
  623. * Returns a `child`’s index within the {@link Container#nodes} array.
  624. *
  625. * @param {Node} child Child of the current container.
  626. *
  627. * @return {number} Child index.
  628. *
  629. * @example
  630. * rule.index( rule.nodes[2] ) //=> 2
  631. */
  632. ;
  633. _proto.index = function index(child) {
  634. if (typeof child === 'number') {
  635. return child;
  636. }
  637. return this.nodes.indexOf(child);
  638. }
  639. /**
  640. * The container’s first child.
  641. *
  642. * @type {Node}
  643. *
  644. * @example
  645. * rule.first === rules.nodes[0]
  646. */
  647. ;
  648. _proto.normalize = function normalize(nodes, sample) {
  649. var _this = this;
  650. if (typeof nodes === 'string') {
  651. var parse = require('./parse');
  652. nodes = cleanSource(parse(nodes).nodes);
  653. } else if (Array.isArray(nodes)) {
  654. nodes = nodes.slice(0);
  655. for (var _iterator8 = nodes, _isArray8 = Array.isArray(_iterator8), _i9 = 0, _iterator8 = _isArray8 ? _iterator8 : _iterator8[Symbol.iterator]();;) {
  656. var _ref8;
  657. if (_isArray8) {
  658. if (_i9 >= _iterator8.length) break;
  659. _ref8 = _iterator8[_i9++];
  660. } else {
  661. _i9 = _iterator8.next();
  662. if (_i9.done) break;
  663. _ref8 = _i9.value;
  664. }
  665. var i = _ref8;
  666. if (i.parent) i.parent.removeChild(i, 'ignore');
  667. }
  668. } else if (nodes.type === 'root') {
  669. nodes = nodes.nodes.slice(0);
  670. for (var _iterator9 = nodes, _isArray9 = Array.isArray(_iterator9), _i10 = 0, _iterator9 = _isArray9 ? _iterator9 : _iterator9[Symbol.iterator]();;) {
  671. var _ref9;
  672. if (_isArray9) {
  673. if (_i10 >= _iterator9.length) break;
  674. _ref9 = _iterator9[_i10++];
  675. } else {
  676. _i10 = _iterator9.next();
  677. if (_i10.done) break;
  678. _ref9 = _i10.value;
  679. }
  680. var _i11 = _ref9;
  681. if (_i11.parent) _i11.parent.removeChild(_i11, 'ignore');
  682. }
  683. } else if (nodes.type) {
  684. nodes = [nodes];
  685. } else if (nodes.prop) {
  686. if (typeof nodes.value === 'undefined') {
  687. throw new Error('Value field is missed in node creation');
  688. } else if (typeof nodes.value !== 'string') {
  689. nodes.value = String(nodes.value);
  690. }
  691. nodes = [new _declaration.default(nodes)];
  692. } else if (nodes.selector) {
  693. var Rule = require('./rule');
  694. nodes = [new Rule(nodes)];
  695. } else if (nodes.name) {
  696. var AtRule = require('./at-rule');
  697. nodes = [new AtRule(nodes)];
  698. } else if (nodes.text) {
  699. nodes = [new _comment.default(nodes)];
  700. } else {
  701. throw new Error('Unknown node type in node creation');
  702. }
  703. var processed = nodes.map(function (i) {
  704. if (i.parent) i.parent.removeChild(i);
  705. if (typeof i.raws.before === 'undefined') {
  706. if (sample && typeof sample.raws.before !== 'undefined') {
  707. i.raws.before = sample.raws.before.replace(/[^\s]/g, '');
  708. }
  709. }
  710. i.parent = _this;
  711. return i;
  712. });
  713. return processed;
  714. }
  715. /**
  716. * @memberof Container#
  717. * @member {Node[]} nodes An array containing the container’s children.
  718. *
  719. * @example
  720. * const root = postcss.parse('a { color: black }')
  721. * root.nodes.length //=> 1
  722. * root.nodes[0].selector //=> 'a'
  723. * root.nodes[0].nodes[0].prop //=> 'color'
  724. */
  725. ;
  726. _createClass(Container, [{
  727. key: "first",
  728. get: function get() {
  729. if (!this.nodes) return undefined;
  730. return this.nodes[0];
  731. }
  732. /**
  733. * The container’s last child.
  734. *
  735. * @type {Node}
  736. *
  737. * @example
  738. * rule.last === rule.nodes[rule.nodes.length - 1]
  739. */
  740. }, {
  741. key: "last",
  742. get: function get() {
  743. if (!this.nodes) return undefined;
  744. return this.nodes[this.nodes.length - 1];
  745. }
  746. }]);
  747. return Container;
  748. }(_node.default);
  749. var _default = Container;
  750. /**
  751. * @callback childCondition
  752. * @param {Node} node Container child.
  753. * @param {number} index Child index.
  754. * @param {Node[]} nodes All container children.
  755. * @return {boolean}
  756. */
  757. /**
  758. * @callback childIterator
  759. * @param {Node} node Container child.
  760. * @param {number} index Child index.
  761. * @return {false|undefined} Returning `false` will break iteration.
  762. */
  763. exports.default = _default;
  764. module.exports = exports.default;
  765. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbnRhaW5lci5lczYiXSwibmFtZXMiOlsiY2xlYW5Tb3VyY2UiLCJub2RlcyI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