source: trip-planner-front/node_modules/autoprefixer/lib/prefixes.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: 13.7 KB
Line 
1"use strict";
2
3function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
4
5function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
7function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
9var vendor = require('postcss').vendor;
10
11var Declaration = require('./declaration');
12
13var Resolution = require('./resolution');
14
15var Transition = require('./transition');
16
17var Processor = require('./processor');
18
19var Supports = require('./supports');
20
21var Browsers = require('./browsers');
22
23var Selector = require('./selector');
24
25var AtRule = require('./at-rule');
26
27var Value = require('./value');
28
29var utils = require('./utils');
30
31Selector.hack(require('./hacks/fullscreen'));
32Selector.hack(require('./hacks/placeholder'));
33Selector.hack(require('./hacks/placeholder-shown'));
34Declaration.hack(require('./hacks/flex'));
35Declaration.hack(require('./hacks/order'));
36Declaration.hack(require('./hacks/filter'));
37Declaration.hack(require('./hacks/grid-end'));
38Declaration.hack(require('./hacks/animation'));
39Declaration.hack(require('./hacks/flex-flow'));
40Declaration.hack(require('./hacks/flex-grow'));
41Declaration.hack(require('./hacks/flex-wrap'));
42Declaration.hack(require('./hacks/grid-area'));
43Declaration.hack(require('./hacks/place-self'));
44Declaration.hack(require('./hacks/grid-start'));
45Declaration.hack(require('./hacks/align-self'));
46Declaration.hack(require('./hacks/appearance'));
47Declaration.hack(require('./hacks/flex-basis'));
48Declaration.hack(require('./hacks/mask-border'));
49Declaration.hack(require('./hacks/mask-composite'));
50Declaration.hack(require('./hacks/align-items'));
51Declaration.hack(require('./hacks/user-select'));
52Declaration.hack(require('./hacks/flex-shrink'));
53Declaration.hack(require('./hacks/break-props'));
54Declaration.hack(require('./hacks/color-adjust'));
55Declaration.hack(require('./hacks/writing-mode'));
56Declaration.hack(require('./hacks/border-image'));
57Declaration.hack(require('./hacks/align-content'));
58Declaration.hack(require('./hacks/border-radius'));
59Declaration.hack(require('./hacks/block-logical'));
60Declaration.hack(require('./hacks/grid-template'));
61Declaration.hack(require('./hacks/inline-logical'));
62Declaration.hack(require('./hacks/grid-row-align'));
63Declaration.hack(require('./hacks/transform-decl'));
64Declaration.hack(require('./hacks/flex-direction'));
65Declaration.hack(require('./hacks/image-rendering'));
66Declaration.hack(require('./hacks/backdrop-filter'));
67Declaration.hack(require('./hacks/background-clip'));
68Declaration.hack(require('./hacks/text-decoration'));
69Declaration.hack(require('./hacks/justify-content'));
70Declaration.hack(require('./hacks/background-size'));
71Declaration.hack(require('./hacks/grid-row-column'));
72Declaration.hack(require('./hacks/grid-rows-columns'));
73Declaration.hack(require('./hacks/grid-column-align'));
74Declaration.hack(require('./hacks/overscroll-behavior'));
75Declaration.hack(require('./hacks/grid-template-areas'));
76Declaration.hack(require('./hacks/text-emphasis-position'));
77Declaration.hack(require('./hacks/text-decoration-skip-ink'));
78Value.hack(require('./hacks/gradient'));
79Value.hack(require('./hacks/intrinsic'));
80Value.hack(require('./hacks/pixelated'));
81Value.hack(require('./hacks/image-set'));
82Value.hack(require('./hacks/cross-fade'));
83Value.hack(require('./hacks/display-flex'));
84Value.hack(require('./hacks/display-grid'));
85Value.hack(require('./hacks/filter-value'));
86var declsCache = {};
87
88var Prefixes = /*#__PURE__*/function () {
89 function Prefixes(data, browsers, options) {
90 if (options === void 0) {
91 options = {};
92 }
93
94 this.data = data;
95 this.browsers = browsers;
96 this.options = options;
97
98 var _this$preprocess = this.preprocess(this.select(this.data));
99
100 this.add = _this$preprocess[0];
101 this.remove = _this$preprocess[1];
102 this.transition = new Transition(this);
103 this.processor = new Processor(this);
104 }
105 /**
106 * Return clone instance to remove all prefixes
107 */
108
109
110 var _proto = Prefixes.prototype;
111
112 _proto.cleaner = function cleaner() {
113 if (this.cleanerCache) {
114 return this.cleanerCache;
115 }
116
117 if (this.browsers.selected.length) {
118 var empty = new Browsers(this.browsers.data, []);
119 this.cleanerCache = new Prefixes(this.data, empty, this.options);
120 } else {
121 return this;
122 }
123
124 return this.cleanerCache;
125 }
126 /**
127 * Select prefixes from data, which is necessary for selected browsers
128 */
129 ;
130
131 _proto.select = function select(list) {
132 var _this = this;
133
134 var selected = {
135 add: {},
136 remove: {}
137 };
138
139 var _loop = function _loop(name) {
140 var data = list[name];
141 var add = data.browsers.map(function (i) {
142 var params = i.split(' ');
143 return {
144 browser: params[0] + " " + params[1],
145 note: params[2]
146 };
147 });
148 var notes = add.filter(function (i) {
149 return i.note;
150 }).map(function (i) {
151 return _this.browsers.prefix(i.browser) + " " + i.note;
152 });
153 notes = utils.uniq(notes);
154 add = add.filter(function (i) {
155 return _this.browsers.isSelected(i.browser);
156 }).map(function (i) {
157 var prefix = _this.browsers.prefix(i.browser);
158
159 if (i.note) {
160 return prefix + " " + i.note;
161 } else {
162 return prefix;
163 }
164 });
165 add = _this.sort(utils.uniq(add));
166
167 if (_this.options.flexbox === 'no-2009') {
168 add = add.filter(function (i) {
169 return !i.includes('2009');
170 });
171 }
172
173 var all = data.browsers.map(function (i) {
174 return _this.browsers.prefix(i);
175 });
176
177 if (data.mistakes) {
178 all = all.concat(data.mistakes);
179 }
180
181 all = all.concat(notes);
182 all = utils.uniq(all);
183
184 if (add.length) {
185 selected.add[name] = add;
186
187 if (add.length < all.length) {
188 selected.remove[name] = all.filter(function (i) {
189 return !add.includes(i);
190 });
191 }
192 } else {
193 selected.remove[name] = all;
194 }
195 };
196
197 for (var name in list) {
198 _loop(name);
199 }
200
201 return selected;
202 }
203 /**
204 * Sort vendor prefixes
205 */
206 ;
207
208 _proto.sort = function sort(prefixes) {
209 return prefixes.sort(function (a, b) {
210 var aLength = utils.removeNote(a).length;
211 var bLength = utils.removeNote(b).length;
212
213 if (aLength === bLength) {
214 return b.length - a.length;
215 } else {
216 return bLength - aLength;
217 }
218 });
219 }
220 /**
221 * Cache prefixes data to fast CSS processing
222 */
223 ;
224
225 _proto.preprocess = function preprocess(selected) {
226 var add = {
227 'selectors': [],
228 '@supports': new Supports(Prefixes, this)
229 };
230
231 for (var name in selected.add) {
232 var prefixes = selected.add[name];
233
234 if (name === '@keyframes' || name === '@viewport') {
235 add[name] = new AtRule(name, prefixes, this);
236 } else if (name === '@resolution') {
237 add[name] = new Resolution(name, prefixes, this);
238 } else if (this.data[name].selector) {
239 add.selectors.push(Selector.load(name, prefixes, this));
240 } else {
241 var props = this.data[name].props;
242
243 if (props) {
244 var value = Value.load(name, prefixes, this);
245
246 for (var _iterator = _createForOfIteratorHelperLoose(props), _step; !(_step = _iterator()).done;) {
247 var prop = _step.value;
248
249 if (!add[prop]) {
250 add[prop] = {
251 values: []
252 };
253 }
254
255 add[prop].values.push(value);
256 }
257 } else {
258 var values = add[name] && add[name].values || [];
259 add[name] = Declaration.load(name, prefixes, this);
260 add[name].values = values;
261 }
262 }
263 }
264
265 var remove = {
266 selectors: []
267 };
268
269 for (var _name in selected.remove) {
270 var _prefixes = selected.remove[_name];
271
272 if (this.data[_name].selector) {
273 var selector = Selector.load(_name, _prefixes);
274
275 for (var _iterator2 = _createForOfIteratorHelperLoose(_prefixes), _step2; !(_step2 = _iterator2()).done;) {
276 var prefix = _step2.value;
277 remove.selectors.push(selector.old(prefix));
278 }
279 } else if (_name === '@keyframes' || _name === '@viewport') {
280 for (var _iterator3 = _createForOfIteratorHelperLoose(_prefixes), _step3; !(_step3 = _iterator3()).done;) {
281 var _prefix = _step3.value;
282
283 var prefixed = "@" + _prefix + _name.slice(1);
284
285 remove[prefixed] = {
286 remove: true
287 };
288 }
289 } else if (_name === '@resolution') {
290 remove[_name] = new Resolution(_name, _prefixes, this);
291 } else {
292 var _props = this.data[_name].props;
293
294 if (_props) {
295 var _value = Value.load(_name, [], this);
296
297 for (var _iterator4 = _createForOfIteratorHelperLoose(_prefixes), _step4; !(_step4 = _iterator4()).done;) {
298 var _prefix2 = _step4.value;
299
300 var old = _value.old(_prefix2);
301
302 if (old) {
303 for (var _iterator5 = _createForOfIteratorHelperLoose(_props), _step5; !(_step5 = _iterator5()).done;) {
304 var _prop = _step5.value;
305
306 if (!remove[_prop]) {
307 remove[_prop] = {};
308 }
309
310 if (!remove[_prop].values) {
311 remove[_prop].values = [];
312 }
313
314 remove[_prop].values.push(old);
315 }
316 }
317 }
318 } else {
319 for (var _iterator6 = _createForOfIteratorHelperLoose(_prefixes), _step6; !(_step6 = _iterator6()).done;) {
320 var p = _step6.value;
321 var olds = this.decl(_name).old(_name, p);
322
323 if (_name === 'align-self') {
324 var a = add[_name] && add[_name].prefixes;
325
326 if (a) {
327 if (p === '-webkit- 2009' && a.includes('-webkit-')) {
328 continue;
329 } else if (p === '-webkit-' && a.includes('-webkit- 2009')) {
330 continue;
331 }
332 }
333 }
334
335 for (var _iterator7 = _createForOfIteratorHelperLoose(olds), _step7; !(_step7 = _iterator7()).done;) {
336 var _prefixed = _step7.value;
337
338 if (!remove[_prefixed]) {
339 remove[_prefixed] = {};
340 }
341
342 remove[_prefixed].remove = true;
343 }
344 }
345 }
346 }
347 }
348
349 return [add, remove];
350 }
351 /**
352 * Declaration loader with caching
353 */
354 ;
355
356 _proto.decl = function decl(prop) {
357 var decl = declsCache[prop];
358
359 if (decl) {
360 return decl;
361 } else {
362 declsCache[prop] = Declaration.load(prop);
363 return declsCache[prop];
364 }
365 }
366 /**
367 * Return unprefixed version of property
368 */
369 ;
370
371 _proto.unprefixed = function unprefixed(prop) {
372 var value = this.normalize(vendor.unprefixed(prop));
373
374 if (value === 'flex-direction') {
375 value = 'flex-flow';
376 }
377
378 return value;
379 }
380 /**
381 * Normalize prefix for remover
382 */
383 ;
384
385 _proto.normalize = function normalize(prop) {
386 return this.decl(prop).normalize(prop);
387 }
388 /**
389 * Return prefixed version of property
390 */
391 ;
392
393 _proto.prefixed = function prefixed(prop, prefix) {
394 prop = vendor.unprefixed(prop);
395 return this.decl(prop).prefixed(prop, prefix);
396 }
397 /**
398 * Return values, which must be prefixed in selected property
399 */
400 ;
401
402 _proto.values = function values(type, prop) {
403 var data = this[type];
404 var global = data['*'] && data['*'].values;
405 var values = data[prop] && data[prop].values;
406
407 if (global && values) {
408 return utils.uniq(global.concat(values));
409 } else {
410 return global || values || [];
411 }
412 }
413 /**
414 * Group declaration by unprefixed property to check them
415 */
416 ;
417
418 _proto.group = function group(decl) {
419 var _this2 = this;
420
421 var rule = decl.parent;
422 var index = rule.index(decl);
423 var length = rule.nodes.length;
424 var unprefixed = this.unprefixed(decl.prop);
425
426 var checker = function checker(step, callback) {
427 index += step;
428
429 while (index >= 0 && index < length) {
430 var other = rule.nodes[index];
431
432 if (other.type === 'decl') {
433 if (step === -1 && other.prop === unprefixed) {
434 if (!Browsers.withPrefix(other.value)) {
435 break;
436 }
437 }
438
439 if (_this2.unprefixed(other.prop) !== unprefixed) {
440 break;
441 } else if (callback(other) === true) {
442 return true;
443 }
444
445 if (step === +1 && other.prop === unprefixed) {
446 if (!Browsers.withPrefix(other.value)) {
447 break;
448 }
449 }
450 }
451
452 index += step;
453 }
454
455 return false;
456 };
457
458 return {
459 up: function up(callback) {
460 return checker(-1, callback);
461 },
462 down: function down(callback) {
463 return checker(+1, callback);
464 }
465 };
466 };
467
468 return Prefixes;
469}();
470
471module.exports = Prefixes;
Note: See TracBrowser for help on using the repository browser.