Skip to content

Commit

Permalink
Use convertToDoc
Browse files Browse the repository at this point in the history
When a DocumentFragment is found in XPathQueryEngine, convert it to a
document first before running evaluate with XPath against it. evaluate
and XPath do not work on DocumentFragments.
  • Loading branch information
ankur22 committed Mar 12, 2024
1 parent 3c9f773 commit 7ce2046
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/js/injected_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ class XPathQueryEngine {
selector = "." + selector;
}
const result = [];

if (root instanceof DocumentFragment) {
root = convertToDoc(root);
}

const document = root instanceof Document ? root : root.ownerDocument;
if (!document) {
return result;
Expand Down

0 comments on commit 7ce2046

Please sign in to comment.