forked from mystiq/hydrogen-web
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
This commit is contained in:
parent
e75f18c87a
commit
48825ea30f
1 changed files with 1 additions and 3 deletions
|
@ -64,9 +64,7 @@ export function parseHTML(html) {
|
||||||
// If DOMPurify uses DOMParser, can't we just get the built tree from it
|
// If DOMPurify uses DOMParser, can't we just get the built tree from it
|
||||||
// instead of re-parsing?
|
// instead of re-parsing?
|
||||||
const sanitized = DOMPurify.sanitize(html, sanitizeConfig);
|
const sanitized = DOMPurify.sanitize(html, sanitizeConfig);
|
||||||
// FIXME: DOMParser from linkedom does not behave the same as the browser,
|
const bodyNode = new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${sanitized}</body></html>`, "text/html").body;
|
||||||
// see https://github.com/WebReflection/linkedom/issues/106
|
|
||||||
const bodyNode = new DOMParser().parseFromString(`<body>${sanitized}</body>`, "text/html").documentElement;
|
|
||||||
|
|
||||||
return new HTMLParseResult(bodyNode);
|
return new HTMLParseResult(bodyNode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue