* Converts an RNode to a helpful readable string value for use in error messages * * @param rNode a given RNode * @param innerContent the content of the node * @returns string
(rNode: RNode, innerContent: string = '…')
| 316 | * @returns string |
| 317 | */ |
| 318 | function describeRNode(rNode: RNode, innerContent: string = '…'): string { |
| 319 | const node = rNode as HTMLElement; |
| 320 | switch (node.nodeType) { |
| 321 | case Node.ELEMENT_NODE: |
| 322 | const tag = node.tagName!.toLowerCase(); |
| 323 | const attrs = stringifyRNodeAttrs(node); |
| 324 | return `<${tag}${attrs ? ' ' + attrs : ''}>${innerContent}</${tag}>`; |
| 325 | case Node.TEXT_NODE: |
| 326 | const content = node.textContent ? shorten(node.textContent) : ''; |
| 327 | return `#text${content ? `(${content})` : ''}`; |
| 328 | case Node.COMMENT_NODE: |
| 329 | return `<!-- ${shorten(node.textContent ?? '')} -->`; |
| 330 | default: |
| 331 | return `#node(${node.nodeType})`; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Builds the string containing the expected DOM present given the LView and TNode |
no test coverage detected
searching dependent graphs…