1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| var packNumber = require('./Number').pack;
| var PERCENTAGE_LENGTH_PROPERTY = {
| 'margin': true,
| 'margin-top': true,
| 'margin-left': true,
| 'margin-bottom': true,
| 'margin-right': true,
|
| 'padding': true,
| 'padding-top': true,
| 'padding-left': true,
| 'padding-bottom': true,
| 'padding-right': true,
|
| 'top': true,
| 'left': true,
| 'bottom': true,
| 'right': true,
|
| 'background-position': true,
| 'background-position-x': true,
| 'background-position-y': true,
| 'background-size': true,
|
| 'border': true,
| 'border-width': true,
| 'border-top-width': true,
| 'border-left-width': true,
| 'border-bottom-width': true,
| 'border-right-width': true,
| 'border-image-width': true,
|
| 'border-radius': true,
| 'border-bottom-left-radius': true,
| 'border-bottom-right-radius': true,
| 'border-top-left-radius': true,
| 'border-top-right-radius': true
| };
|
| module.exports = function compressPercentage(node, item) {
| var value = packNumber(node.value, item);
| var property = this.declaration !== null ? this.declaration.property : null;
|
| node.value = value;
|
| if (property !== null && PERCENTAGE_LENGTH_PROPERTY.hasOwnProperty(property)) {
| if (value === '0') {
| item.data = {
| type: 'Number',
| loc: node.loc,
| value: value
| };
| }
| }
| };
|
|