Loading homepage
Find a node at the same structural position in another DOM tree, including text and comment nodes.
Input: // Tree A: <div><p>First</p><button>Save</button></div> // Tree B: <div><p>Second</p><button>Submit</button></div> getCorrespondingNode(rootA, rootB, rootA.childNodes[1]); Output: Returns the existing button node from tree B.
Input: getCorrespondingNode(rootA, rootB, rootA); Output: Returns rootB itself.
Implement the exported DOM utility in index.js or index.ts. Tests provide fixtures for the required behavior.