( node1: Node, node2: IRRNode, domMirror: NodeMirror, rrdomMirror: Mirror, )
| 597 | * To check whether two nodes are matching. If so, they are supposed to have the same serialized Id and node type. If they are both Elements, their tagNames should be the same as well. Otherwise, they are not matching. |
| 598 | */ |
| 599 | export function nodeMatching( |
| 600 | node1: Node, |
| 601 | node2: IRRNode, |
| 602 | domMirror: NodeMirror, |
| 603 | rrdomMirror: Mirror, |
| 604 | ): boolean { |
| 605 | const node1Id = domMirror.getId(node1); |
| 606 | const node2Id = rrdomMirror.getId(node2); |
| 607 | // rrdom contains elements with negative ids, we don't want to accidentally match those to a mirror mismatch (-1) id. |
| 608 | // Negative oldStartId happen when nodes are not in the mirror, but are in the DOM. |
| 609 | // eg.iframes come with a document, html, head and body nodes. |
| 610 | // thats why below we always check if an id is negative. |
| 611 | if (node1Id === -1 || node1Id !== node2Id) return false; |
| 612 | return sameNodeType(node1, node2); |
| 613 | } |
no test coverage detected