(key: string, value: string)
| 1144 | } |
| 1145 | |
| 1146 | export function canonicalizeValue(key: string, value: string): string { |
| 1147 | const trimmed = value.trim().toLowerCase() |
| 1148 | |
| 1149 | if (/^0+(\.0+)?(px|%|rem|em)?$/.test(trimmed)) { |
| 1150 | return '0' |
| 1151 | } |
| 1152 | |
| 1153 | if (key === 'color') { |
| 1154 | const hex = canonicalizeColor(trimmed) |
| 1155 | if (hex) return hex |
| 1156 | } |
| 1157 | |
| 1158 | if (key === 'font-weight') { |
| 1159 | if (trimmed === 'normal') return '400' |
| 1160 | if (trimmed === 'bold') return '700' |
| 1161 | } |
| 1162 | |
| 1163 | if (key === 'line-height' && trimmed === 'normal') { |
| 1164 | return 'normal' |
| 1165 | } |
| 1166 | |
| 1167 | return trimmed.replace(ALL_WHITESPACE_RE, '') |
| 1168 | } |
| 1169 | |
| 1170 | function formatHex(r: number, g: number, b: number): string { |
| 1171 | const toHex = (n: number) => n.toString(16).padStart(2, '0') |
no test coverage detected