MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / pruneInheritedTextStyles

Function pruneInheritedTextStyles

packages/extension/utils/css.ts:1124–1144  ·  view source on GitHub ↗
(
  style: Record<string, string>,
  ...bases: Array<Record<string, string> | undefined>
)

Source from the content-addressed store, hash-verified

1122}
1123
1124export 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
1146export function canonicalizeValue(key: string, value: string): string {
1147 const trimmed = value.trim().toLowerCase()

Callers 2

css.test.tsFile · 0.90
renderTextSegmentsFunction · 0.90

Calls 2

canonicalizeValueFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected