Make sure initial comments are preserved in HTML editor (#1647)

This commit is contained in:
Henrik Giesel 2022-02-08 05:07:09 +01:00 committed by GitHub
parent 9a80524560
commit 16e9e56ad8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,11 +55,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
} }
function parseAsHTML(html: string): string { function createDummyDoc(html: string): string {
const doc = parser.parseFromString( return (
parsingInstructions.join("") + html, "<html><head></head><body>" +
"text/html", parsingInstructions.join("") +
html +
"</body>"
); );
}
function parseAsHTML(html: string): string {
const doc = parser.parseFromString(createDummyDoc(html), "text/html");
const body = doc.body; const body = doc.body;
removeTag(body, "script"); removeTag(body, "script");