source: trip-planner-front/node_modules/autoprefixer/lib/value.js@ 6fe77af

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

initial commit

  • Property mode set to 100644
File size: 3.7 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
7var vendor = require('postcss').vendor;
8
9var Prefixer = require('./prefixer');
10
11var OldValue = require('./old-value');
12
13var utils = require('./utils');
14
15var Value = /*#__PURE__*/function (_Prefixer) {
16 _inheritsLoose(Value, _Prefixer);
17
18 function Value() {
19 return _Prefixer.apply(this, arguments) || this;
20 }
21
22 /**
23 * Clone decl for each prefixed values
24 */
25 Value.save = function save(prefixes, decl) {
26 var _this = this;
27
28 var prop = decl.prop;
29 var result = [];
30
31 var _loop = function _loop(prefix) {
32 var value = decl._autoprefixerValues[prefix];
33
34 if (value === decl.value) {
35 return "continue";
36 }
37
38 var item = void 0;
39 var propPrefix = vendor.prefix(prop);
40
41 if (propPrefix === '-pie-') {
42 return "continue";
43 }
44
45 if (propPrefix === prefix) {
46 item = decl.value = value;
47 result.push(item);
48 return "continue";
49 }
50
51 var prefixed = prefixes.prefixed(prop, prefix);
52 var rule = decl.parent;
53
54 if (!rule.every(function (i) {
55 return i.prop !== prefixed;
56 })) {
57 result.push(item);
58 return "continue";
59 }
60
61 var trimmed = value.replace(/\s+/, ' ');
62 var already = rule.some(function (i) {
63 return i.prop === decl.prop && i.value.replace(/\s+/, ' ') === trimmed;
64 });
65
66 if (already) {
67 result.push(item);
68 return "continue";
69 }
70
71 var cloned = _this.clone(decl, {
72 value: value
73 });
74
75 item = decl.parent.insertBefore(decl, cloned);
76 result.push(item);
77 };
78
79 for (var prefix in decl._autoprefixerValues) {
80 var _ret = _loop(prefix);
81
82 if (_ret === "continue") continue;
83 }
84
85 return result;
86 }
87 /**
88 * Is declaration need to be prefixed
89 */
90 ;
91
92 var _proto = Value.prototype;
93
94 _proto.check = function check(decl) {
95 var value = decl.value;
96
97 if (!value.includes(this.name)) {
98 return false;
99 }
100
101 return !!value.match(this.regexp());
102 }
103 /**
104 * Lazy regexp loading
105 */
106 ;
107
108 _proto.regexp = function regexp() {
109 return this.regexpCache || (this.regexpCache = utils.regexp(this.name));
110 }
111 /**
112 * Add prefix to values in string
113 */
114 ;
115
116 _proto.replace = function replace(string, prefix) {
117 return string.replace(this.regexp(), "$1" + prefix + "$2");
118 }
119 /**
120 * Get value with comments if it was not changed
121 */
122 ;
123
124 _proto.value = function value(decl) {
125 if (decl.raws.value && decl.raws.value.value === decl.value) {
126 return decl.raws.value.raw;
127 } else {
128 return decl.value;
129 }
130 }
131 /**
132 * Save values with next prefixed token
133 */
134 ;
135
136 _proto.add = function add(decl, prefix) {
137 if (!decl._autoprefixerValues) {
138 decl._autoprefixerValues = {};
139 }
140
141 var value = decl._autoprefixerValues[prefix] || this.value(decl);
142 var before;
143
144 do {
145 before = value;
146 value = this.replace(value, prefix);
147 if (value === false) return;
148 } while (value !== before);
149
150 decl._autoprefixerValues[prefix] = value;
151 }
152 /**
153 * Return function to fast find prefixed value
154 */
155 ;
156
157 _proto.old = function old(prefix) {
158 return new OldValue(this.name, prefix + this.name);
159 };
160
161 return Value;
162}(Prefixer);
163
164module.exports = Value;
Note: See TracBrowser for help on using the repository browser.