how to document.createRange().createContextualFragment(html) in a service worker ?

i'm working on a web extension, and it does a fetch. the result is the HTML, and i want to search elements in that HTML. usually, i do a createRange().. in order to be able to querySelector(). but since it's in a service worker. i don't have access to the document. how can i manage this ? thanks. here is my 'not working code'
fetch(myUrl)
.then(res => res.text())
.then(html => {
const page = document.createRange().createContextualFragment(html); // ReferenceError: document is not defined
});
fetch(myUrl)
.then(res => res.text())
.then(html => {
const page = document.createRange().createContextualFragment(html); // ReferenceError: document is not defined
});
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server