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.3 KB
|
Line | |
---|
1 | var split = require('../../../utils/split');
|
---|
2 |
|
---|
3 | var ANY_FUNCTION_PATTERN = /^(-(?:moz|ms|o|webkit)-[a-z-]+|[a-z-]+)\((.+)\)$/;
|
---|
4 | var SKIP_FUNCTION_PATTERN = /^(?:-moz-calc|-webkit-calc|calc|rgb|hsl|rgba|hsla|min|max|clamp|expression)\(/;
|
---|
5 | var TOKEN_SEPARATOR_PATTERN = /([\s,/])/;
|
---|
6 |
|
---|
7 | function removeRecursively(value, options) {
|
---|
8 | var functionTokens;
|
---|
9 | var tokens;
|
---|
10 |
|
---|
11 | if (SKIP_FUNCTION_PATTERN.test(value)) {
|
---|
12 | return value;
|
---|
13 | }
|
---|
14 |
|
---|
15 | functionTokens = ANY_FUNCTION_PATTERN.exec(value);
|
---|
16 |
|
---|
17 | if (!functionTokens) {
|
---|
18 | return removeZeros(value, options);
|
---|
19 | }
|
---|
20 |
|
---|
21 | tokens = split(functionTokens[2], TOKEN_SEPARATOR_PATTERN)
|
---|
22 | .map(function(token) { return removeRecursively(token, options); });
|
---|
23 |
|
---|
24 | return functionTokens[1] + '(' + tokens.join('') + ')';
|
---|
25 | }
|
---|
26 |
|
---|
27 | function removeZeros(value, options) {
|
---|
28 | return value
|
---|
29 | .replace(options.unitsRegexp, '$10$2')
|
---|
30 | .replace(options.unitsRegexp, '$10$2');
|
---|
31 | }
|
---|
32 |
|
---|
33 | var plugin = {
|
---|
34 | level1: {
|
---|
35 | value: function zero(name, value, options) {
|
---|
36 | if (!options.compatibility.properties.zeroUnits) {
|
---|
37 | return value;
|
---|
38 | }
|
---|
39 |
|
---|
40 | if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height' || name == 'width' || name == 'max-width')) {
|
---|
41 | return value;
|
---|
42 | }
|
---|
43 |
|
---|
44 | return removeRecursively(value, options);
|
---|
45 | }
|
---|
46 | }
|
---|
47 | };
|
---|
48 |
|
---|
49 | module.exports = plugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.