source: trip-planner-front/node_modules/autoprefixer/lib/resolution.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: 4.5 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 _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); }
6
7function _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); }
8
9function _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; }
10
11function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
12
13var n2f = require('num2fraction');
14
15var Prefixer = require('./prefixer');
16
17var utils = require('./utils');
18
19var REGEXP = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpi|x)/gi;
20var SPLIT = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpi|x)/i;
21
22var Resolution = /*#__PURE__*/function (_Prefixer) {
23 _inheritsLoose(Resolution, _Prefixer);
24
25 function Resolution() {
26 return _Prefixer.apply(this, arguments) || this;
27 }
28
29 var _proto = Resolution.prototype;
30
31 /**
32 * Return prefixed query name
33 */
34 _proto.prefixName = function prefixName(prefix, name) {
35 if (prefix === '-moz-') {
36 return name + '--moz-device-pixel-ratio';
37 } else {
38 return prefix + name + '-device-pixel-ratio';
39 }
40 }
41 /**
42 * Return prefixed query
43 */
44 ;
45
46 _proto.prefixQuery = function prefixQuery(prefix, name, colon, value, units) {
47 if (units === 'dpi') {
48 value = Number(value / 96);
49 }
50
51 if (prefix === '-o-') {
52 value = n2f(value);
53 }
54
55 return this.prefixName(prefix, name) + colon + value;
56 }
57 /**
58 * Remove prefixed queries
59 */
60 ;
61
62 _proto.clean = function clean(rule) {
63 var _this = this;
64
65 if (!this.bad) {
66 this.bad = [];
67
68 for (var _iterator = _createForOfIteratorHelperLoose(this.prefixes), _step; !(_step = _iterator()).done;) {
69 var prefix = _step.value;
70 this.bad.push(this.prefixName(prefix, 'min'));
71 this.bad.push(this.prefixName(prefix, 'max'));
72 }
73 }
74
75 rule.params = utils.editList(rule.params, function (queries) {
76 return queries.filter(function (query) {
77 return _this.bad.every(function (i) {
78 return !query.includes(i);
79 });
80 });
81 });
82 }
83 /**
84 * Add prefixed queries
85 */
86 ;
87
88 _proto.process = function process(rule) {
89 var _this2 = this;
90
91 var parent = this.parentPrefix(rule);
92 var prefixes = parent ? [parent] : this.prefixes;
93 rule.params = utils.editList(rule.params, function (origin, prefixed) {
94 for (var _iterator2 = _createForOfIteratorHelperLoose(origin), _step2; !(_step2 = _iterator2()).done;) {
95 var query = _step2.value;
96
97 if (!query.includes('min-resolution') && !query.includes('max-resolution')) {
98 prefixed.push(query);
99 continue;
100 }
101
102 var _loop = function _loop() {
103 var prefix = _step3.value;
104 var processed = query.replace(REGEXP, function (str) {
105 var parts = str.match(SPLIT);
106 return _this2.prefixQuery(prefix, parts[1], parts[2], parts[3], parts[4]);
107 });
108 prefixed.push(processed);
109 };
110
111 for (var _iterator3 = _createForOfIteratorHelperLoose(prefixes), _step3; !(_step3 = _iterator3()).done;) {
112 _loop();
113 }
114
115 prefixed.push(query);
116 }
117
118 return utils.uniq(prefixed);
119 });
120 };
121
122 return Resolution;
123}(Prefixer);
124
125module.exports = Resolution;
Note: See TracBrowser for help on using the repository browser.