Skip to content

Commit

Permalink
fix(ssr): reuse constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Feb 6, 2022
1 parent 37359e2 commit be15fa8
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/ssr/toVNode.ts
@@ -1,4 +1,4 @@
import { DomHandler, Parser } from 'htmlparser2';
import { parseDocument } from 'htmlparser2';
import { h } from '../jsx-runtime/h';
import { DOMNode, OLD_VNODE_FIELD, VNode, Flags } from '../million/types';

Expand Down Expand Up @@ -40,9 +40,5 @@ export const domNodeToVNode = (el: DOMNode): VNode | undefined => {
};

export const toVNode = (html: string): VNode => {
const handler = new DomHandler();
const parser = new Parser(handler);
parser.write(html);
parser.end();
return nodeToVNode(handler.dom[0]);
return nodeToVNode(parseDocument(html).children[0]);
};

0 comments on commit be15fa8

Please sign in to comment.