source: trip-planner-front/node_modules/autoprefixer/lib/hacks/mask-composite.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.2 KB
Line 
1"use strict";
2
3function _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
5function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
6
7function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
9var Declaration = require('../declaration');
10
11var MaskComposite = /*#__PURE__*/function (_Declaration) {
12 _inheritsLoose(MaskComposite, _Declaration);
13
14 function MaskComposite() {
15 return _Declaration.apply(this, arguments) || this;
16 }
17
18 var _proto = MaskComposite.prototype;
19
20 /**
21 * Prefix mask-composite for webkit
22 */
23 _proto.insert = function insert(decl, prefix, prefixes) {
24 var isCompositeProp = decl.prop === 'mask-composite';
25 var compositeValues;
26
27 if (isCompositeProp) {
28 compositeValues = decl.value.split(',');
29 } else {
30 compositeValues = decl.value.match(MaskComposite.regexp) || [];
31 }
32
33 compositeValues = compositeValues.map(function (el) {
34 return el.trim();
35 }).filter(function (el) {
36 return el;
37 });
38 var hasCompositeValues = compositeValues.length;
39 var compositeDecl;
40
41 if (hasCompositeValues) {
42 compositeDecl = this.clone(decl);
43 compositeDecl.value = compositeValues.map(function (value) {
44 return MaskComposite.oldValues[value] || value;
45 }).join(', ');
46
47 if (compositeValues.includes('intersect')) {
48 compositeDecl.value += ', xor';
49 }
50
51 compositeDecl.prop = prefix + 'mask-composite';
52 }
53
54 if (isCompositeProp) {
55 if (!hasCompositeValues) {
56 return undefined;
57 }
58
59 if (this.needCascade(decl)) {
60 compositeDecl.raws.before = this.calcBefore(prefixes, decl, prefix);
61 }
62
63 return decl.parent.insertBefore(decl, compositeDecl);
64 }
65
66 var cloned = this.clone(decl);
67 cloned.prop = prefix + cloned.prop;
68
69 if (hasCompositeValues) {
70 cloned.value = cloned.value.replace(MaskComposite.regexp, '');
71 }
72
73 if (this.needCascade(decl)) {
74 cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
75 }
76
77 decl.parent.insertBefore(decl, cloned);
78
79 if (!hasCompositeValues) {
80 return decl;
81 }
82
83 if (this.needCascade(decl)) {
84 compositeDecl.raws.before = this.calcBefore(prefixes, decl, prefix);
85 }
86
87 return decl.parent.insertBefore(decl, compositeDecl);
88 };
89
90 return MaskComposite;
91}(Declaration);
92
93_defineProperty(MaskComposite, "names", ['mask', 'mask-composite']);
94
95_defineProperty(MaskComposite, "oldValues", {
96 add: 'source-over',
97 substract: 'source-out',
98 intersect: 'source-in',
99 exclude: 'xor'
100});
101
102_defineProperty(MaskComposite, "regexp", new RegExp("\\s+(" + Object.keys(MaskComposite.oldValues).join('|') + ")\\b(?!\\))\\s*(?=[,])", 'ig'));
103
104module.exports = MaskComposite;
Note: See TracBrowser for help on using the repository browser.