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 _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
|
6 |
|
7 | var Prefixer = require('./prefixer');
|
8 |
|
9 | var AtRule =
|
10 |
|
11 | function (_Prefixer) {
|
12 | _inheritsLoose(AtRule, _Prefixer);
|
13 |
|
14 | function AtRule() {
|
15 | return _Prefixer.apply(this, arguments) || this;
|
16 | }
|
17 |
|
18 | var _proto = AtRule.prototype;
|
19 |
|
20 | |
21 |
|
22 |
|
23 | _proto.add = function add(rule, prefix) {
|
24 | var prefixed = prefix + rule.name;
|
25 | var already = rule.parent.some(function (i) {
|
26 | return i.name === prefixed && i.params === rule.params;
|
27 | });
|
28 |
|
29 | if (already) {
|
30 | return undefined;
|
31 | }
|
32 |
|
33 | var cloned = this.clone(rule, {
|
34 | name: prefixed
|
35 | });
|
36 | return rule.parent.insertBefore(rule, cloned);
|
37 | }
|
38 | |
39 |
|
40 |
|
41 | ;
|
42 |
|
43 | _proto.process = function process(node) {
|
44 | var parent = this.parentPrefix(node);
|
45 |
|
46 | for (var _iterator = this.prefixes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
47 | var _ref;
|
48 |
|
49 | if (_isArray) {
|
50 | if (_i >= _iterator.length) break;
|
51 | _ref = _iterator[_i++];
|
52 | } else {
|
53 | _i = _iterator.next();
|
54 | if (_i.done) break;
|
55 | _ref = _i.value;
|
56 | }
|
57 |
|
58 | var prefix = _ref;
|
59 |
|
60 | if (!parent || parent === prefix) {
|
61 | this.add(node, prefix);
|
62 | }
|
63 | }
|
64 | };
|
65 |
|
66 | return AtRule;
|
67 | }(Prefixer);
|
68 |
|
69 | module.exports = AtRule; |
\ | No newline at end of file |