123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 'use strict';
- const blurInterpolation = require('./blurInterpolation');
- const isStandardSyntaxValue = require('./isStandardSyntaxValue');
- const valueParser = require('postcss-value-parser');
- module.exports = function (node) {
- if (!node || !node.value) {
- return {
- unit: null,
- number: null,
- };
- }
-
- if (node.type !== 'word') {
- return {
- unit: null,
- number: null,
- };
- }
-
- if (!isStandardSyntaxValue(node.value)) {
- return {
- unit: null,
- number: null,
- };
- }
-
- if (node.value.startsWith('#')) {
- return {
- unit: null,
- number: null,
- };
- }
-
- const value = blurInterpolation(node.value, '')
-
- .replace('\\0', '')
- .replace('\\9', '');
- const parsedUnit = valueParser.unit(value);
- if (!parsedUnit) {
- return {
- unit: null,
- number: null,
- };
- }
- return parsedUnit;
- };
|