129 lines
8.6 KiB
JavaScript
129 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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImF0LXJ1bGUuZXM2Il0sIm5hbWVzIjpbIkF0U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