( style: Record<string, string>, ...bases: Array<Record<string, string> | undefined> )
| 1122 | } |
| 1123 | |
| 1124 | export function pruneInheritedTextStyles( |
| 1125 | style: Record<string, string>, |
| 1126 | ...bases: Array<Record<string, string> | undefined> |
| 1127 | ): void { |
| 1128 | Object.entries(style).forEach(([key, value]) => { |
| 1129 | const normalizedCurrent = canonicalizeValue(key, value) |
| 1130 | |
| 1131 | for (const base of bases) { |
| 1132 | const inheritedValue = base?.[key] |
| 1133 | if (inheritedValue && canonicalizeValue(key, inheritedValue) === normalizedCurrent) { |
| 1134 | delete style[key] |
| 1135 | return |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | const defaultValue = TEXT_STYLE_DEFAULTS.get(key) |
| 1140 | if (defaultValue && canonicalizeValue(key, defaultValue) === normalizedCurrent) { |
| 1141 | delete style[key] |
| 1142 | } |
| 1143 | }) |
| 1144 | } |
| 1145 | |
| 1146 | export function canonicalizeValue(key: string, value: string): string { |
| 1147 | const trimmed = value.trim().toLowerCase() |
no test coverage detected