.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / autoprefixer / lib / hacks / display-flex.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 flexSpec = require('./flex-spec');
12 var OldValue = require('../old-value');
13 var Value = require('../value');
14
15 var DisplayFlex = function (_Value) {
16     _inherits(DisplayFlex, _Value);
17
18     function DisplayFlex(name, prefixes) {
19         _classCallCheck(this, DisplayFlex);
20
21         var _this = _possibleConstructorReturn(this, _Value.call(this, name, prefixes));
22
23         if (name === 'display-flex') {
24             _this.name = 'flex';
25         }
26         return _this;
27     }
28
29     /**
30      * Faster check for flex value
31      */
32
33
34     DisplayFlex.prototype.check = function check(decl) {
35         return decl.prop === 'display' && decl.value === this.name;
36     };
37
38     /**
39      * Return value by spec
40      */
41
42
43     DisplayFlex.prototype.prefixed = function prefixed(prefix) {
44         var spec = void 0,
45             value = void 0;
46
47         var _flexSpec = flexSpec(prefix);
48
49         spec = _flexSpec[0];
50         prefix = _flexSpec[1];
51
52
53         if (spec === 2009) {
54             if (this.name === 'flex') {
55                 value = 'box';
56             } else {
57                 value = 'inline-box';
58             }
59         } else if (spec === 2012) {
60             if (this.name === 'flex') {
61                 value = 'flexbox';
62             } else {
63                 value = 'inline-flexbox';
64             }
65         } else if (spec === 'final') {
66             value = this.name;
67         }
68
69         return prefix + value;
70     };
71
72     /**
73      * Add prefix to value depend on flebox spec version
74      */
75
76
77     DisplayFlex.prototype.replace = function replace(string, prefix) {
78         return this.prefixed(prefix);
79     };
80
81     /**
82      * Change value for old specs
83      */
84
85
86     DisplayFlex.prototype.old = function old(prefix) {
87         var prefixed = this.prefixed(prefix);
88         if (!prefixed) return undefined;
89         return new OldValue(this.name, prefixed);
90     };
91
92     return DisplayFlex;
93 }(Value);
94
95 Object.defineProperty(DisplayFlex, 'names', {
96     enumerable: true,
97     writable: true,
98     value: ['display-flex', 'inline-flex']
99 });
100
101
102 module.exports = DisplayFlex;