fix: use DOMParser from globalThis

This commit is contained in:
thecodrr
2022-07-15 09:42:30 +05:00
parent da38c8cb8a
commit 0a05ec3cbd

View File

@@ -1,13 +1,10 @@
import { decodeHTML5 } from "entities";
import { DOMParser } from "linkedom/worker";
const RealDOMParser =
"window" in global && "DOMParser" in window
? new window.DOMParser()
: new DOMParser();
export const parseHTML = (input) =>
RealDOMParser.parseFromString(wrapIntoHTMLDocument(input), "text/html");
new globalThis.DOMParser().parseFromString(
wrapIntoHTMLDocument(input),
"text/html"
);
export function getDummyDocument() {
const doc = parseHTML("<div></div>");