Matt-Esch / virtual-dom

A Virtual DOM and diffing algorithm
MIT License
11.65k stars 780 forks source link

Question: HTML string to vTree #439

Closed davidworkman9 closed 6 years ago

davidworkman9 commented 6 years ago

I'm wondering if there's a way I can seed the virtual-dom with a HTML string, without using eval. Below works, using dom2hscript to parse an HTML string into a hyperscript string, then eval it with virtual-dom/h in global scope, however using eval and polluting the global namespace are two things I'd like to avoid.

const lastOutput = eval(dom2hscript.parseHTML(html));
const el = createElement(lastOutput);
hallgren commented 6 years ago

I use vdom-parser to parse html strings into Vtree´s in Krumelur

davidworkman9 commented 6 years ago

@hallgren thanks that's exactly what I was looking for!