(n: any)
| 192 | }); |
| 193 | |
| 194 | function elementText(n: any): string { |
| 195 | const hasNodes = (n: any) => { |
| 196 | const children = n.childNodes; |
| 197 | return children && children.length > 0; |
| 198 | }; |
| 199 | |
| 200 | if (n instanceof Array) { |
| 201 | return n.map(elementText).join(''); |
| 202 | } |
| 203 | |
| 204 | if (isCommentNode(n)) { |
| 205 | return ''; |
| 206 | } |
| 207 | |
| 208 | if (getDOM().isElementNode(n)) { |
| 209 | const tagName = (n as Element).tagName; |
| 210 | |
| 211 | if (tagName === 'CONTENT') { |
| 212 | return elementText(Array.prototype.slice.apply((<any>n).getDistributedNodes())); |
| 213 | } else if (tagName === 'SLOT') { |
| 214 | return elementText(Array.prototype.slice.apply((<any>n).assignedNodes())); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if (hasShadowRoot(n)) { |
| 219 | return elementText(childNodesAsList((<any>n).shadowRoot)); |
| 220 | } |
| 221 | |
| 222 | if (hasNodes(n)) { |
| 223 | return elementText(childNodesAsList(n)); |
| 224 | } |
| 225 | |
| 226 | return (n as any).textContent; |
| 227 | } |
| 228 | |
| 229 | function hasShadowRoot(node: any): boolean { |
| 230 | return node.shadowRoot != null && node instanceof HTMLElement; |
no test coverage detected
searching dependent graphs…