Skip to content

Commit 0a71683

Browse files
asamuzaKdomenic
authored andcommitted
Refactor calc name assignment in parsePropertyValue
Replaces hardcoded 'calc' string with the variable 'name' when assigning the 'name' property in parsedValues. This improves code maintainability and consistency for function parsing.
1 parent b6a4e5f commit 0a71683

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

lib/parsers.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,33 +326,32 @@ const parsePropertyValue = (prop, val, opt = {}) => {
326326
const raw = items.length === 1 ? val : css;
327327
// Remove "${name}(" from the start and ")" from the end
328328
const itemValue = raw.slice(name.length + 1, -1).trim();
329-
330329
if (name === "calc") {
331330
if (children.length === 1) {
332331
const [child] = children;
333332
if (child.type === AST_TYPES.NUMBER) {
334333
parsedValues.push({
335334
type: AST_TYPES.CALC,
336-
name: "calc",
337335
isNumber: true,
338336
value: `${parseFloat(child.value)}`,
337+
name,
339338
raw
340339
});
341340
} else {
342341
parsedValues.push({
343342
type: AST_TYPES.CALC,
344-
name: "calc",
345343
isNumber: false,
346344
value: `${asciiLowercase(itemValue)}`,
345+
name,
347346
raw
348347
});
349348
}
350349
} else {
351350
parsedValues.push({
352351
type: AST_TYPES.CALC,
353-
name: "calc",
354352
isNumber: false,
355353
value: asciiLowercase(itemValue),
354+
name,
356355
raw
357356
});
358357
}

0 commit comments

Comments
 (0)