(
style: Record<string, string>,
replacements: Map<string, string>,
{ preserveInlineFallbacks = false }: VariableStyleOptions = {}
)
| 190 | } |
| 191 | |
| 192 | function rewriteInlineVars( |
| 193 | style: Record<string, string>, |
| 194 | replacements: Map<string, string>, |
| 195 | { preserveInlineFallbacks = false }: VariableStyleOptions = {} |
| 196 | ): void { |
| 197 | if (!replacements.size) return |
| 198 | |
| 199 | for (const [key, value] of Object.entries(style)) { |
| 200 | if (!value || !value.includes('var(')) continue |
| 201 | |
| 202 | style[key] = replaceVarFunctions(value, ({ full, name, fallback }) => { |
| 203 | const replacement = replacements.get(normalizeCustomPropertyName(name.trim())) |
| 204 | if (!replacement) return full |
| 205 | if (preserveInlineFallbacks && fallback && replacement.startsWith('var(')) { |
| 206 | return replacement.replace(/\)$/, `, ${fallback})`) |
| 207 | } |
| 208 | return replacement |
| 209 | }) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | function applyBoundFields( |
| 214 | style: Record<string, string>, |
no test coverage detected