.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / autoprefixer / lib / hacks / break-props.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 Declaration = require('../declaration');
12
13 var BreakProps = function (_Declaration) {
14     _inherits(BreakProps, _Declaration);
15
16     function BreakProps() {
17         _classCallCheck(this, BreakProps);
18
19         return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20     }
21
22     /**
23      * Change name for -webkit- and -moz- prefix
24      */
25     BreakProps.prototype.prefixed = function prefixed(prop, prefix) {
26         if (prefix === '-moz-') {
27             return 'page-' + prop;
28         } else {
29             return prefix + 'column-' + prop;
30         }
31     };
32
33     /**
34      * Return property name by final spec
35      */
36
37
38     BreakProps.prototype.normalize = function normalize(prop) {
39         if (prop.indexOf('inside') !== -1) {
40             return 'break-inside';
41         } else if (prop.indexOf('before') !== -1) {
42             return 'break-before';
43         } else {
44             return 'break-after';
45         }
46     };
47
48     /**
49      * Change prefixed value for avoid-column and avoid-page
50      */
51
52
53     BreakProps.prototype.set = function set(decl, prefix) {
54         if (decl.prop === 'break-inside' && decl.value === 'avoid-column' || decl.value === 'avoid-page') {
55             decl.value = 'avoid';
56         }
57         return _Declaration.prototype.set.call(this, decl, prefix);
58     };
59
60     /**
61      * Don’t prefix some values
62      */
63
64
65     BreakProps.prototype.insert = function insert(decl, prefix, prefixes) {
66         if (decl.prop !== 'break-inside') {
67             return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
68         } else if (decl.value === 'avoid-region') {
69             return undefined;
70         } else if (decl.value === 'avoid-page' && prefix === '-webkit-') {
71             return undefined;
72         } else {
73             return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
74         }
75     };
76
77     return BreakProps;
78 }(Declaration);
79
80 Object.defineProperty(BreakProps, 'names', {
81     enumerable: true,
82     writable: true,
83     value: ['break-inside', 'page-break-inside', 'column-break-inside', 'break-before', 'page-break-before', 'column-break-before', 'break-after', 'page-break-after', 'column-break-after']
84 });
85
86
87 module.exports = BreakProps;