feat: find root document

This commit is contained in:
karishmas6
2024-06-05 10:36:27 +05:30
parent a2d4dfb68c
commit 24bdea4c10

View File

@@ -131,6 +131,15 @@ export const getSelectors = async (page: Page, coordinates: Coordinates) => {
}
function findRootDocument(rootNode: Element | Document, defaults: Options) {
if (rootNode.nodeType === Node.DOCUMENT_NODE) {
return rootNode;
}
if (rootNode === defaults.root) {
return rootNode.ownerDocument as Document;
}
return rootNode;
}
}