Skip to content

Commit

Permalink
fix(204): strip doctype before jsx is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
skippednote committed Jun 20, 2020
1 parent 5437e5f commit 8f18366
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/svelte2tsx/src/htmlxtojsx.ts
Expand Up @@ -20,6 +20,11 @@ const beforeStart = (start: number) => start - 1;

type Walker = (node: Node, parent: Node, prop: string, index: number) => void;

const stripDoctype = (str: MagicString) => {
const result = /<!doctype.+>/i.exec(str.original);
if (result) str.remove(result.index, result[0].length);
};

// eslint-disable-next-line max-len
export function convertHtmlxToJsx(
str: MagicString,
Expand All @@ -28,6 +33,7 @@ export function convertHtmlxToJsx(
onLeave: Walker = null,
) {
const htmlx = str.original;
stripDoctype(str);
str.prepend('<>');
str.append('</>');
const handleRaw = (rawBlock: Node) => {
Expand Down

0 comments on commit 8f18366

Please sign in to comment.