You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
8.6 KiB

4 years ago
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = void 0;
  4. var _container = _interopRequireDefault(require("./container"));
  5. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7. /**
  8. * Represents an at-rule.
  9. *
  10. * If its followed in the CSS by a {} block, this node will have
  11. * a nodes property representing its children.
  12. *
  13. * @extends Container
  14. *
  15. * @example
  16. * const root = postcss.parse('@charset "UTF-8"; @media print {}')
  17. *
  18. * const charset = root.first
  19. * charset.type //=> 'atrule'
  20. * charset.nodes //=> undefined
  21. *
  22. * const media = root.last
  23. * media.nodes //=> []
  24. */
  25. var AtRule =
  26. /*#__PURE__*/
  27. function (_Container) {
  28. _inheritsLoose(AtRule, _Container);
  29. function AtRule(defaults) {
  30. var _this;
  31. _this = _Container.call(this, defaults) || this;
  32. _this.type = 'atrule';
  33. return _this;
  34. }
  35. var _proto = AtRule.prototype;
  36. _proto.append = function append() {
  37. var _Container$prototype$;
  38. if (!this.nodes) this.nodes = [];
  39. for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
  40. children[_key] = arguments[_key];
  41. }
  42. return (_Container$prototype$ = _Container.prototype.append).call.apply(_Container$prototype$, [this].concat(children));
  43. };
  44. _proto.prepend = function prepend() {
  45. var _Container$prototype$2;
  46. if (!this.nodes) this.nodes = [];
  47. for (var _len2 = arguments.length, children = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  48. children[_key2] = arguments[_key2];
  49. }
  50. return (_Container$prototype$2 = _Container.prototype.prepend).call.apply(_Container$prototype$2, [this].concat(children));
  51. }
  52. /**
  53. * @memberof AtRule#
  54. * @member {string} name The at-rules name immediately follows the `@`.
  55. *
  56. * @example
  57. * const root = postcss.parse('@media print {}')
  58. * media.name //=> 'media'
  59. * const media = root.first
  60. */
  61. /**
  62. * @memberof AtRule#
  63. * @member {string} params The at-rules parameters, the values
  64. * that follow the at-rules name but precede
  65. * any {} block.
  66. *
  67. * @example
  68. * const root = postcss.parse('@media print, screen {}')
  69. * const media = root.first
  70. * media.params //=> 'print, screen'
  71. */
  72. /**
  73. * @memberof AtRule#
  74. * @member {object} raws Information to generate byte-to-byte equal
  75. * node string as it was in the origin input.
  76. *
  77. * Every parser saves its own properties,
  78. * but the default CSS parser uses:
  79. *
  80. * * `before`: the space symbols before the node. It also stores `*`
  81. * and `_` symbols before the declaration (IE hack).
  82. * * `after`: the space symbols after the last child of the node
  83. * to the end of the node.
  84. * * `between`: the symbols between the property and value
  85. * for declarations, selector and `{` for rules, or last parameter
  86. * and `{` for at-rules.
  87. * * `semicolon`: contains true if the last child has
  88. * an (optional) semicolon.
  89. * * `afterName`: the space between the at-rule name and its parameters.
  90. *
  91. * PostCSS cleans at-rule parameters from comments and extra spaces,
  92. * but it stores origin content in raws properties.
  93. * As such, if you dont change a declarations value,
  94. * PostCSS will use the raw value with comments.
  95. *
  96. * @example
  97. * const root = postcss.parse(' @media\nprint {\n}')
  98. * root.first.first.raws //=> { before: ' ',
  99. * // between: ' ',
  100. * // afterName: '\n',
  101. * // after: '\n' }
  102. */
  103. ;
  104. return AtRule;
  105. }(_container.default);
  106. var _default = AtRule;
  107. exports.default = _default;
  108. module.exports = exports.default;
  109. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImF0LXJ1bGUuZXM2Il0sIm5hbWVzIjpbIkF0UnVsZSIsImRlZmF1bHRzIiwidHlwZSIsImFwcGVuZCIsIm5vZGVzIiwiY2hpbGRyZW4iLCJwcmVwZW5kIiwiQ29udGFpbmVyIl0sIm1hcHBpbmdzIjoiOzs7OztBQUFBOzs7Ozs7QUFFQTs7Ozs7Ozs7Ozs7Ozs7Ozs7O0lBa0JNQ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