( element: Element, includeWeight: boolean = false, )
| 18 | import type Store from './store'; |
| 19 | |
| 20 | export function printElement( |
| 21 | element: Element, |
| 22 | includeWeight: boolean = false, |
| 23 | ): string { |
| 24 | let prefix = ' '; |
| 25 | if (element.children.length > 0) { |
| 26 | prefix = element.isCollapsed ? '▸' : '▾'; |
| 27 | } |
| 28 | |
| 29 | let key = ''; |
| 30 | if (element.key !== null) { |
| 31 | key = ` key="${element.key}"`; |
| 32 | } |
| 33 | |
| 34 | let name = ''; |
| 35 | if (element.nameProp !== null) { |
| 36 | name = ` name="${element.nameProp}"`; |
| 37 | } |
| 38 | |
| 39 | let hocDisplayNames = null; |
| 40 | if (element.hocDisplayNames !== null) { |
| 41 | hocDisplayNames = [...element.hocDisplayNames]; |
| 42 | } |
| 43 | |
| 44 | const hocs = |
| 45 | hocDisplayNames === null ? '' : ` [${hocDisplayNames.join('][')}]`; |
| 46 | |
| 47 | let suffix = ''; |
| 48 | if (includeWeight) { |
| 49 | suffix = ` (${element.isCollapsed ? 1 : element.weight})`; |
| 50 | } |
| 51 | |
| 52 | return `${' '.repeat(element.depth + 1)}${prefix} <${ |
| 53 | element.displayName || 'null' |
| 54 | }${key}${name}>${hocs}${suffix}`; |
| 55 | } |
| 56 | |
| 57 | function printRects(rects: SuspenseNode['rects']): string { |
| 58 | if (rects === null) { |
no test coverage detected