1 | 'use strict';
|
2 |
|
3 | const blurInterpolation = require('./blurInterpolation');
|
4 | const isStandardSyntaxValue = require('./isStandardSyntaxValue');
|
5 | const valueParser = require('postcss-value-parser');
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | module.exports = function (node) {
|
17 | if (!node || !node.value) {
|
18 | return null;
|
19 | }
|
20 |
|
21 |
|
22 | if (node.type !== 'word') {
|
23 | return null;
|
24 | }
|
25 |
|
26 |
|
27 | if (!isStandardSyntaxValue(node.value)) {
|
28 | return null;
|
29 | }
|
30 |
|
31 |
|
32 | if (node.value.startsWith('#')) {
|
33 | return null;
|
34 | }
|
35 |
|
36 |
|
37 | const value = blurInterpolation(node.value, '')
|
38 |
|
39 | .replace('\\0', '')
|
40 | .replace('\\9', '');
|
41 |
|
42 | const parsedUnit = valueParser.unit(value);
|
43 |
|
44 | if (!parsedUnit) {
|
45 | return null;
|
46 | }
|
47 |
|
48 | return parsedUnit.unit;
|
49 | };
|