mirror of
https://github.com/thangisme/notes.git
synced 2024-11-05 12:47:16 -05:00
137 lines
11 KiB
JavaScript
137 lines
11 KiB
JavaScript
'use strict';
|
||
|
||
exports.__esModule = true;
|
||
|
||
var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
var _container = require('./container');
|
||
|
||
var _container2 = _interopRequireDefault(_container);
|
||
|
||
var _warnOnce = require('./warn-once');
|
||
|
||
var _warnOnce2 = _interopRequireDefault(_warnOnce);
|
||
|
||
var _list = require('./list');
|
||
|
||
var _list2 = _interopRequireDefault(_list);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : 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 = function (_Container) {
|
||
_inherits(Rule, _Container);
|
||
|
||
function Rule(defaults) {
|
||
_classCallCheck(this, Rule);
|
||
|
||
var _this = _possibleConstructorReturn(this, _Container.call(this, defaults));
|
||
|
||
_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 _list2.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);
|
||
}
|
||
}, {
|
||
key: '_selector',
|
||
get: function get() {
|
||
(0, _warnOnce2.default)('Rule#_selector is deprecated. Use Rule#raws.selector');
|
||
return this.raws.selector;
|
||
},
|
||
set: function set(val) {
|
||
(0, _warnOnce2.default)('Rule#_selector is deprecated. Use Rule#raws.selector');
|
||
this.raws.selector = val;
|
||
}
|
||
|
||
/**
|
||
* @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.
|
||
*
|
||
* 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;
|
||
}(_container2.default);
|
||
|
||
exports.default = Rule;
|
||
module.exports = exports['default'];
|
||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGUuZXM2Il0sIm5hbWVzIjpbIlJ1bGUiLCJkZWZhdWx0cyIsInR5cGUiLCJub2RlcyIsImNvbW1hIiwic2VsZWN0b3IiLCJ2YWx1ZXMiLCJtYXRjaCIsInNlcCIsInJhdyIsImpvaW4iLCJyYXdzIiwidmFsIl0sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQTs7OztBQUNBOzs7O0FBQ0E7Ozs7Ozs7Ozs7OztBQUVBOzs7Ozs7Ozs7OztJQVdNQSxJOzs7QUFFRixrQkFBWUMsUUFBWixFQUFzQjtBQUFBOztBQUFBLHFEQUNsQixzQkFBTUEsUUFBTixDQURrQjs7QUFFbEIsY0FBS0MsSUFBTCxHQUFZLE1BQVo7QUFDQSxZQUFLLENBQUMsTUFBS0MsS0FBWCxFQUFtQixNQUFLQSxLQUFMLEdBQWEsRUFBYjtBQUhEO0FBSXJCOztBQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs0QkFnQmdCO0FBQ1osbUJBQU8sZUFBS0MsS0FBTCxDQUFXLEtBQUtDLFFBQWh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