.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / autoprefixer / lib / hacks / intrinsic.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 OldValue = require('../old-value');
12 var Value = require('../value');
13
14 function _regexp(name) {
15     return new RegExp('(^|[\\s,(])(' + name + '($|[\\s),]))', 'gi');
16 }
17
18 var Intrinsic = function (_Value) {
19     _inherits(Intrinsic, _Value);
20
21     function Intrinsic() {
22         _classCallCheck(this, Intrinsic);
23
24         return _possibleConstructorReturn(this, _Value.apply(this, arguments));
25     }
26
27     Intrinsic.prototype.regexp = function regexp() {
28         if (!this.regexpCache) this.regexpCache = _regexp(this.name);
29         return this.regexpCache;
30     };
31
32     Intrinsic.prototype.isStretch = function isStretch() {
33         return this.name === 'stretch' || this.name === 'fill' || this.name === 'fill-available';
34     };
35
36     Intrinsic.prototype.replace = function replace(string, prefix) {
37         if (prefix === '-moz-' && this.isStretch()) {
38             return string.replace(this.regexp(), '$1-moz-available$3');
39         } else if (prefix === '-webkit-' && this.isStretch()) {
40             return string.replace(this.regexp(), '$1-webkit-fill-available$3');
41         } else {
42             return _Value.prototype.replace.call(this, string, prefix);
43         }
44     };
45
46     Intrinsic.prototype.old = function old(prefix) {
47         var prefixed = prefix + this.name;
48         if (this.isStretch()) {
49             if (prefix === '-moz-') {
50                 prefixed = '-moz-available';
51             } else if (prefix === '-webkit-') {
52                 prefixed = '-webkit-fill-available';
53             }
54         }
55         return new OldValue(this.name, prefixed, prefixed, _regexp(prefixed));
56     };
57
58     Intrinsic.prototype.add = function add(decl, prefix) {
59         if (decl.prop.indexOf('grid') !== -1 && prefix !== '-webkit-') {
60             return undefined;
61         }
62         return _Value.prototype.add.call(this, decl, prefix);
63     };
64
65     return Intrinsic;
66 }(Value);
67
68 Object.defineProperty(Intrinsic, 'names', {
69     enumerable: true,
70     writable: true,
71     value: ['max-content', 'min-content', 'fit-content', 'fill', 'fill-available', 'stretch']
72 });
73
74
75 module.exports = Intrinsic;