From 48825ea30ff024bffe15c21af72242c9d43bfa1e Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 11 Feb 2022 19:23:45 -0600 Subject: [PATCH] Use explicit HTML document boilerplate to get consistent results in browser and linkedom (for SSR) Context: - https://github.com/WebReflection/linkedom/issues/106 - https://github.com/WebReflection/linkedom/pull/108 --- src/platform/web/parsehtml.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/platform/web/parsehtml.js b/src/platform/web/parsehtml.js index 6689c518..1e646d10 100644 --- a/src/platform/web/parsehtml.js +++ b/src/platform/web/parsehtml.js @@ -64,9 +64,7 @@ export function parseHTML(html) { // If DOMPurify uses DOMParser, can't we just get the built tree from it // instead of re-parsing? const sanitized = DOMPurify.sanitize(html, sanitizeConfig); - // FIXME: DOMParser from linkedom does not behave the same as the browser, - // see https://github.com/WebReflection/linkedom/issues/106 - const bodyNode = new DOMParser().parseFromString(`${sanitized}`, "text/html").documentElement; + const bodyNode = new DOMParser().parseFromString(`${sanitized}`, "text/html").body; return new HTMLParseResult(bodyNode); }