|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
exports.__esModule = true;
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _container = _interopRequireDefault(require("./container"));
|
|
|
|
|
|
|
|
|
|
var _list = _interopRequireDefault(require("./list"));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
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); } }
|
|
|
|
|
|
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
|
|
|
|
|
|
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Represents a CSS rule: a selector followed by a declaration block.
|
|
|
|
|
*
|
|
|
|
|
* @extends Container
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* const root = postcss.parse('a{}')
|
|
|
|
|
* const rule = root.first
|
|
|
|
|
* rule.type //=> 'rule'
|
|
|
|
|
* rule.toString() //=> 'a{}'
|
|
|
|
|
*/
|
|
|
|
|
var Rule =
|
|
|
|
|
/*#__PURE__*/
|
|
|
|
|
function (_Container) {
|
|
|
|
|
_inheritsLoose(Rule, _Container);
|
|
|
|
|
|
|
|
|
|
function Rule(defaults) {
|
|
|
|
|
var _this;
|
|
|
|
|
|
|
|
|
|
_this = _Container.call(this, defaults) || this;
|
|
|
|
|
_this.type = 'rule';
|
|
|
|
|
if (!_this.nodes) _this.nodes = [];
|
|
|
|
|
return _this;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* An array containing the rule’s individual selectors.
|
|
|
|
|
* Groups of selectors are split at commas.
|
|
|
|
|
*
|
|
|
|
|
* @type {string[]}
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* const root = postcss.parse('a, b { }')
|
|
|
|
|
* const rule = root.first
|
|
|
|
|
*
|
|
|
|
|
* rule.selector //=> 'a, b'
|
|
|
|
|
* rule.selectors //=> ['a', 'b']
|
|
|
|
|
*
|
|
|
|
|
* rule.selectors = ['a', 'strong']
|
|
|
|
|
* rule.selector //=> 'a, strong'
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_createClass(Rule, [{
|
|
|
|
|
key: "selectors",
|
|
|
|
|
get: function get() {
|
|
|
|
|
return _list.default.comma(this.selector);
|
|
|
|
|
},
|
|
|
|
|
set: function set(values) {
|
|
|
|
|
var match = this.selector ? this.selector.match(/,\s*/) : null;
|
|
|
|
|
var sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
|
|
|
|
|
this.selector = values.join(sep);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @memberof Rule#
|
|
|
|
|
* @member {string} selector The rule’s full selector represented
|
|
|
|
|
* as a string.
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
* const root = postcss.parse('a, b { }')
|
|
|
|
|
* const rule = root.first
|
|
|
|
|
* rule.selector //=> 'a, b'
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @memberof Rule#
|
|
|
|
|
* @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.
|
|
|
|
|
* * `ownSemicolon`: contains `true` if there is semicolon after rule.
|
|
|
|
|
*
|
|
|
|
|
* PostCSS cleans selectors 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('a {\n color:black\n}')
|
|
|
|
|
* root.first.first.raws //=> { before: '', between: ' ', after: '\n' }
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
return Rule;
|
|
|
|
|
}(_container.default);
|
|
|
|
|
|
|
|
|
|
var _default = Rule;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
module.exports = exports.default;
|
|
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGUuZXM2Il0sIm5hbWVzIjpbIlJ1bGUiLCJkZWZhdWx0cyIsInR5cGUiLCJub2RlcyIsImxpc3QiLCJjb21tYSIsInNlbGVjdG9yIiwidmFsdWVzIiwibWF0Y2giLCJzZXAiLCJyYXciLCJqb2luIiwiQ29udGFpbmVyIl0sIm1hcHBpbmdzIjoiOzs7OztBQUFBOztBQUNBOzs7Ozs7Ozs7O0FBRUE7Ozs7Ozs7Ozs7O0lBV01BLEk7Ozs7O0FBQ0osZ0JBQWFDLFFBQWIsRUFBdUI7QUFBQTs7QUFDckIsa0NBQU1BLFFBQU47QUFDQSxVQUFLQyxJQUFMLEdBQVksTUFBWjtBQUNBLFFBQUksQ0FBQyxNQUFLQyxLQUFWLEVBQWlCLE1BQUtBLEtBQUwsR0FBYSx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