( immutableFormaters: Array<DevToolsFormatter>, item: Element | JsonMLElementList )
| 66 | } |
| 67 | |
| 68 | function normalizeElement( |
| 69 | immutableFormaters: Array<DevToolsFormatter>, |
| 70 | item: Element | JsonMLElementList |
| 71 | ): Element | JsonMLElementList { |
| 72 | if (!Array.isArray(item)) { |
| 73 | return item; |
| 74 | } |
| 75 | |
| 76 | if (!isElement(item)) { |
| 77 | return item; |
| 78 | } |
| 79 | |
| 80 | const explodedItem = explodeElement(item); |
| 81 | |
| 82 | const { tagName, attributes, children } = explodedItem; |
| 83 | |
| 84 | const normalizedChildren = children.map((child) => |
| 85 | normalizeResult(immutableFormaters, child) |
| 86 | ); |
| 87 | |
| 88 | if (attributes) { |
| 89 | // @ts-expect-error type is not perfect here because of self-reference |
| 90 | return [tagName, attributes, ...normalizedChildren]; |
| 91 | } |
| 92 | |
| 93 | return [tagName, ...normalizedChildren]; |
| 94 | } |
no test coverage detected