Skip to content

Commit 9c46dcb

Browse files
Copilotsawka
andcommitted
Remove DOM fallback from color validator
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
1 parent 7ed95d9 commit 9c46dcb

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

frontend/util/color-validator.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@ const FunctionalColorRegex = /^([a-z-]+)\(/i;
33
const NamedColorRegex = /^[a-z]+$/i;
44

55
function isValidCssColor(color: string): boolean {
6-
if (typeof CSS != "undefined" && typeof CSS.supports == "function") {
7-
return CSS.supports("color", color);
8-
}
9-
if (typeof document == "undefined") {
6+
if (typeof CSS == "undefined" || typeof CSS.supports != "function") {
107
return false;
118
}
12-
const temp = document.createElement("div");
13-
temp.style.color = "";
14-
temp.style.color = color;
15-
return temp.style.color != "";
9+
return CSS.supports("color", color);
1610
}
1711

1812
function getCssColorType(color: string): string {

0 commit comments

Comments
 (0)