127 lines
8.6 KiB
JavaScript
127 lines
8.6 KiB
JavaScript
"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 _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
||
|
||
/**
|
||
* Represents an at-rule.
|
||
*
|
||
* If it’s followed in the CSS by a {} block, this node will have
|
||
* a nodes property representing its children.
|
||
*
|
||
* @extends Container
|
||
*
|
||
* @example
|
||
* const root = postcss.parse('@charset "UTF-8"; @media print {}')
|
||
*
|
||
* const charset = root.first
|
||
* charset.type //=> 'atrule'
|
||
* charset.nodes //=> undefined
|
||
*
|
||
* const media = root.last
|
||
* media.nodes //=> []
|
||
*/
|
||
var AtRule = /*#__PURE__*/function (_Container) {
|
||
_inheritsLoose(AtRule, _Container);
|
||
|
||
function AtRule(defaults) {
|
||
var _this;
|
||
|
||
_this = _Container.call(this, defaults) || this;
|
||
_this.type = 'atrule';
|
||
return _this;
|
||
}
|
||
|
||
var _proto = AtRule.prototype;
|
||
|
||
_proto.append = function append() {
|
||
var _Container$prototype$;
|
||
|
||
if (!this.nodes) this.nodes = [];
|
||
|
||
for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
|
||
children[_key] = arguments[_key];
|
||
}
|
||
|
||
return (_Container$prototype$ = _Container.prototype.append).call.apply(_Container$prototype$, [this].concat(children));
|
||
};
|
||
|
||
_proto.prepend = function prepend() {
|
||
var _Container$prototype$2;
|
||
|
||
if (!this.nodes) this.nodes = [];
|
||
|
||
for (var _len2 = arguments.length, children = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||
children[_key2] = arguments[_key2];
|
||
}
|
||
|
||
return (_Container$prototype$2 = _Container.prototype.prepend).call.apply(_Container$prototype$2, [this].concat(children));
|
||
}
|
||
/**
|
||
* @memberof AtRule#
|
||
* @member {string} name The at-rule’s name immediately follows the `@`.
|
||
*
|
||
* @example
|
||
* const root = postcss.parse('@media print {}')
|
||
* media.name //=> 'media'
|
||
* const media = root.first
|
||
*/
|
||
|
||
/**
|
||
* @memberof AtRule#
|
||
* @member {string} params The at-rule’s parameters, the values
|
||
* that follow the at-rule’s name but precede
|
||
* any {} block.
|
||
*
|
||
* @example
|
||
* const root = postcss.parse('@media print, screen {}')
|
||
* const media = root.first
|
||
* media.params //=> 'print, screen'
|
||
*/
|
||
|
||
/**
|
||
* @memberof AtRule#
|
||
* @member {object} raws Information to generate byte-to-byte equal
|
||
* node string as it was in the origin input.
|
||
*
|
||
* Every parser saves its own properties,
|
||
* but the default CSS parser uses:
|
||
*
|
||
* * `before`: the space symbols before the node. It also stores `*`
|
||
* and `_` symbols before the declaration (IE hack).
|
||
* * `after`: the space symbols after the last child of the node
|
||
* to the end of the node.
|
||
* * `between`: the symbols between the property and value
|
||
* for declarations, selector and `{` for rules, or last parameter
|
||
* and `{` for at-rules.
|
||
* * `semicolon`: contains true if the last child has
|
||
* an (optional) semicolon.
|
||
* * `afterName`: the space between the at-rule name and its parameters.
|
||
*
|
||
* PostCSS cleans at-rule parameters from comments and extra spaces,
|
||
* but it stores origin content in raws properties.
|
||
* As such, if you don’t change a declaration’s value,
|
||
* PostCSS will use the raw value with comments.
|
||
*
|
||
* @example
|
||
* const root = postcss.parse(' @media\nprint {\n}')
|
||
* root.first.first.raws //=> { before: ' ',
|
||
* // between: ' ',
|
||
* // afterName: '\n',
|
||
* // after: '\n' }
|
||
*/
|
||
;
|
||
|
||
return AtRule;
|
||
}(_container.default);
|
||
|
||
var _default = AtRule;
|
||
exports.default = _default;
|
||
module.exports = exports.default;
|
||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImF0LXJ1bGUuZXM2Il0sIm5hbWVzIjpbIkF0UnVsZSIsImRl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