.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / autoprefixer / lib / at-rule.js
1 'use strict';
2
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; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
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; }
8
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); }
10
11 var Prefixer = require('./prefixer');
12
13 var AtRule = function (_Prefixer) {
14     _inherits(AtRule, _Prefixer);
15
16     function AtRule() {
17         _classCallCheck(this, AtRule);
18
19         return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
20     }
21
22     /**
23      * Clone and add prefixes for at-rule
24      */
25     AtRule.prototype.add = function add(rule, prefix) {
26         var prefixed = prefix + rule.name;
27
28         var already = rule.parent.some(function (i) {
29             return i.name === prefixed && i.params === rule.params;
30         });
31         if (already) {
32             return undefined;
33         }
34
35         var cloned = this.clone(rule, { name: prefixed });
36         return rule.parent.insertBefore(rule, cloned);
37     };
38
39     /**
40      * Clone node with prefixes
41      */
42
43
44     AtRule.prototype.process = function process(node) {
45         var parent = this.parentPrefix(node);
46
47         for (var _iterator = this.prefixes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
48             var _ref;
49
50             if (_isArray) {
51                 if (_i >= _iterator.length) break;
52                 _ref = _iterator[_i++];
53             } else {
54                 _i = _iterator.next();
55                 if (_i.done) break;
56                 _ref = _i.value;
57             }
58
59             var prefix = _ref;
60
61             if (!parent || parent === prefix) {
62                 this.add(node, prefix);
63             }
64         }
65     };
66
67     return AtRule;
68 }(Prefixer);
69
70 module.exports = AtRule;