Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | var lexer = require('css-tree').lexer;
|
---|
2 | var packNumber = require('./Number').pack;
|
---|
3 | var blacklist = new Set([
|
---|
4 | // see https://github.com/jakubpawlowicz/clean-css/issues/957
|
---|
5 | 'width',
|
---|
6 | 'min-width',
|
---|
7 | 'max-width',
|
---|
8 | 'height',
|
---|
9 | 'min-height',
|
---|
10 | 'max-height',
|
---|
11 |
|
---|
12 | // issue #410: Don’t remove units in flex-basis value for (-ms-)flex shorthand
|
---|
13 | // issue #362: shouldn't remove unit in -ms-flex since it breaks flex in IE10/11
|
---|
14 | // issue #200: shouldn't remove unit in flex since it breaks flex in IE10/11
|
---|
15 | 'flex',
|
---|
16 | '-ms-flex'
|
---|
17 | ]);
|
---|
18 |
|
---|
19 | module.exports = function compressPercentage(node, item) {
|
---|
20 | node.value = packNumber(node.value, item);
|
---|
21 |
|
---|
22 | if (node.value === '0' && this.declaration && !blacklist.has(this.declaration.property)) {
|
---|
23 | // try to convert a number
|
---|
24 | item.data = {
|
---|
25 | type: 'Number',
|
---|
26 | loc: node.loc,
|
---|
27 | value: node.value
|
---|
28 | };
|
---|
29 |
|
---|
30 | // that's ok only when new value matches on length
|
---|
31 | if (!lexer.matchDeclaration(this.declaration).isType(item.data, 'length')) {
|
---|
32 | // otherwise rollback changes
|
---|
33 | item.data = node;
|
---|
34 | }
|
---|
35 | }
|
---|
36 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.