source: trip-planner-front/node_modules/csso/lib/replace/Dimension.js@ 84d0fbb

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

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1var packNumber = require('./Number').pack;
2var MATH_FUNCTIONS = {
3 'calc': true,
4 'min': true,
5 'max': true,
6 'clamp': true
7};
8var LENGTH_UNIT = {
9 // absolute length units
10 'px': true,
11 'mm': true,
12 'cm': true,
13 'in': true,
14 'pt': true,
15 'pc': true,
16
17 // relative length units
18 'em': true,
19 'ex': true,
20 'ch': true,
21 'rem': true,
22
23 // viewport-percentage lengths
24 'vh': true,
25 'vw': true,
26 'vmin': true,
27 'vmax': true,
28 'vm': true
29};
30
31module.exports = function compressDimension(node, item) {
32 var value = packNumber(node.value, item);
33
34 node.value = value;
35
36 if (value === '0' && this.declaration !== null && this.atrulePrelude === null) {
37 var unit = node.unit.toLowerCase();
38
39 // only length values can be compressed
40 if (!LENGTH_UNIT.hasOwnProperty(unit)) {
41 return;
42 }
43
44 // issue #362: shouldn't remove unit in -ms-flex since it breaks flex in IE10/11
45 // issue #200: shouldn't remove unit in flex since it breaks flex in IE10/11
46 if (this.declaration.property === '-ms-flex' ||
47 this.declaration.property === 'flex') {
48 return;
49 }
50
51 // issue #222: don't remove units inside calc
52 if (this.function && MATH_FUNCTIONS.hasOwnProperty(this.function.name)) {
53 return;
54 }
55
56 item.data = {
57 type: 'Number',
58 loc: node.loc,
59 value: value
60 };
61 }
62};
Note: See TracBrowser for help on using the repository browser.