(a: VNode, b: VNode)
| 64 | } |
| 65 | |
| 66 | export function leafVNodeEqual(a: VNode, b: VNode): boolean { |
| 67 | switch (a.kind) { |
| 68 | case "text": { |
| 69 | if (b.kind !== "text") return false; |
| 70 | if (a.text !== b.text) return false; |
| 71 | if (a.props === b.props) return true; |
| 72 | const ap = a.props as { |
| 73 | id?: unknown; |
| 74 | style?: unknown; |
| 75 | textOverflow?: unknown; |
| 76 | variant?: unknown; |
| 77 | maxWidth?: unknown; |
| 78 | }; |
| 79 | const bp = b.props as { |
| 80 | id?: unknown; |
| 81 | style?: unknown; |
| 82 | textOverflow?: unknown; |
| 83 | variant?: unknown; |
| 84 | maxWidth?: unknown; |
| 85 | }; |
| 86 | if (ap.id !== bp.id) return false; |
| 87 | if (ap.textOverflow !== bp.textOverflow) return false; |
| 88 | if (ap.variant !== bp.variant) return false; |
| 89 | if (ap.maxWidth !== bp.maxWidth) return false; |
| 90 | return textStyleEqual( |
| 91 | ap.style as Parameters<typeof textStyleEqual>[0], |
| 92 | bp.style as Parameters<typeof textStyleEqual>[0], |
| 93 | ); |
| 94 | } |
| 95 | case "spacer": { |
| 96 | if (b.kind !== "spacer") return false; |
| 97 | const ap = a.props as { size?: number; flex?: number }; |
| 98 | const bp = b.props as { size?: number; flex?: number }; |
| 99 | return ap.size === bp.size && ap.flex === bp.flex; |
| 100 | } |
| 101 | case "divider": { |
| 102 | if (b.kind !== "divider") return false; |
| 103 | const ap = a.props as { |
| 104 | direction?: unknown; |
| 105 | char?: unknown; |
| 106 | label?: unknown; |
| 107 | color?: unknown; |
| 108 | }; |
| 109 | const bp = b.props as { |
| 110 | direction?: unknown; |
| 111 | char?: unknown; |
| 112 | label?: unknown; |
| 113 | color?: unknown; |
| 114 | }; |
| 115 | return ( |
| 116 | ap.direction === bp.direction && |
| 117 | ap.char === bp.char && |
| 118 | ap.label === bp.label && |
| 119 | ap.color === bp.color |
| 120 | ); |
| 121 | } |
| 122 | case "richText": { |
| 123 | if (b.kind !== "richText") return false; |
no test coverage detected