3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7 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; }
9 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) : _defaults(subClass, superClass); }
11 var Prefixer = require('./prefixer');
13 var AtRule = function (_Prefixer) {
14 _inherits(AtRule, _Prefixer);
17 _classCallCheck(this, AtRule);
19 return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
23 * Clone and add prefixes for at-rule
25 AtRule.prototype.add = function add(rule, prefix) {
26 var prefixed = prefix + rule.name;
28 var already = rule.parent.some(function (i) {
29 return i.name === prefixed && i.params === rule.params;
35 var cloned = this.clone(rule, { name: prefixed });
36 return rule.parent.insertBefore(rule, cloned);
40 * Clone node with prefixes
44 AtRule.prototype.process = function process(node) {
45 var parent = this.parentPrefix(node);
47 for (var _iterator = this.prefixes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
51 if (_i >= _iterator.length) break;
52 _ref = _iterator[_i++];
54 _i = _iterator.next();
61 if (!parent || parent === prefix) {
62 this.add(node, prefix);
70 module.exports = AtRule;