(prop: string, value: string, rule: CSSStyleRule)
| 306 | ]); |
| 307 | |
| 308 | function getColorModifier(prop: string, value: string, rule: CSSStyleRule): string | CSSValueModifier | null { |
| 309 | if ( |
| 310 | unparsableColors.has(value.toLowerCase()) && |
| 311 | !(prop === 'color' && value === 'initial') |
| 312 | ) { |
| 313 | return value; |
| 314 | } |
| 315 | let rgb: RGBA | null = null; |
| 316 | if (prop === 'color' && value === 'initial') { |
| 317 | rgb = {r: 0, g: 0, b: 0, a: 1}; |
| 318 | } else { |
| 319 | rgb = parseColorWithCache(value); |
| 320 | } |
| 321 | if (!rgb) { |
| 322 | logWarn("Couldn't parse color", value); |
| 323 | return null; |
| 324 | } |
| 325 | |
| 326 | if (prop.includes('background')) { |
| 327 | const maskImageValue = rule.style.maskImage ?? rule.style.mask; |
| 328 | if ( |
| 329 | maskImageValue && |
| 330 | !maskImageValue.startsWith('none') && |
| 331 | !maskImageValue.startsWith('linear-gradient') |
| 332 | ) { |
| 333 | return (theme) => modifyForegroundColor(rgb, theme); |
| 334 | } |
| 335 | return (theme) => modifyBackgroundColor(rgb, theme); |
| 336 | } |
| 337 | if (prop.includes('border') || prop.includes('outline')) { |
| 338 | return (theme) => modifyBorderColor(rgb, theme); |
| 339 | } |
| 340 | return (theme) => modifyForegroundColor(rgb, theme); |
| 341 | } |
| 342 | |
| 343 | const imageDetailsCache = new Map<string, ImageDetails>(); |
| 344 | const awaitingForImageLoading = new Map<string, Array<(imageDetails: ImageDetails | null) => void>>(); |
no test coverage detected