source: imaps-frontend/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/unit.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
Line 
1var WHOLE_PIXEL_VALUE = /(?:^|\s|\()(-?\d+)px/;
2
3var plugin = {
4 level1: {
5 value: function unit(_name, value, options) {
6 if (!WHOLE_PIXEL_VALUE.test(value)) {
7 return value;
8 }
9
10 return value.replace(WHOLE_PIXEL_VALUE, function(match, val) {
11 var newValue;
12 var intVal = parseInt(val);
13
14 if (intVal === 0) {
15 return match;
16 }
17
18 if (options.compatibility.properties.shorterLengthUnits
19 && options.compatibility.units.pt
20 && intVal * 3 % 4 === 0) {
21 newValue = intVal * 3 / 4 + 'pt';
22 }
23
24 if (options.compatibility.properties.shorterLengthUnits
25 && options.compatibility.units.pc
26 && intVal % 16 === 0) {
27 newValue = intVal / 16 + 'pc';
28 }
29
30 if (options.compatibility.properties.shorterLengthUnits
31 && options.compatibility.units.in
32 && intVal % 96 === 0) {
33 newValue = intVal / 96 + 'in';
34 }
35
36 if (newValue) {
37 newValue = match.substring(0, match.indexOf(val)) + newValue;
38 }
39
40 return newValue && newValue.length < match.length ? newValue : match;
41 });
42 }
43 }
44};
45
46module.exports = plugin;
Note: See TracBrowser for help on using the repository browser.