Skip to content

Commit 4af17f5

Browse files
authored
feat: add infinity support for CSS properties (#84)
1 parent 172a683 commit 4af17f5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/compiler/declarations.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,8 @@ export function parseUnparsed(
12021202
return true;
12031203
} else if (value === "false") {
12041204
return false;
1205+
} else if (value === "infinity") {
1206+
return Number.MAX_SAFE_INTEGER;
12051207
} else {
12061208
return value;
12071209
}
@@ -1309,7 +1311,12 @@ export function parseLength(
13091311
} else if (length.value === -Infinity) {
13101312
return -9999;
13111313
} else {
1312-
return round(length.value);
1314+
// Normalize large values to safe integers, e.g. `calc(infinity * 1px)`
1315+
const value = Math.max(
1316+
Math.min(length.value, Number.MAX_SAFE_INTEGER),
1317+
Number.MIN_SAFE_INTEGER,
1318+
);
1319+
return round(value);
13131320
}
13141321
}
13151322
case "rem":

0 commit comments

Comments
 (0)