(node: Node)
| 78 | * See `getNextSibling` for more information on clobbering. |
| 79 | */ |
| 80 | export function getFirstChild(node: Node): Node | null { |
| 81 | const firstChild = node.firstChild; |
| 82 | // Make sure there is no `firstChild` clobbering: the real first child has |
| 83 | // `node` as its parent and no previous sibling. Note that checking whether |
| 84 | // the node is a descendant isn't enough, since a clobbering form control is |
| 85 | // typically located inside the form itself. |
| 86 | if (firstChild && (firstChild.parentNode !== node || firstChild.previousSibling !== null)) { |
| 87 | throw clobberedElementError(firstChild); |
| 88 | } |
| 89 | return firstChild; |
| 90 | } |
| 91 | |
| 92 | /** Gets a reasonable nodeName, even for clobbered nodes. */ |
| 93 | export function getNodeName(node: Node): string { |
no test coverage detected