Matt-Esch / virtual-dom

A Virtual DOM and diffing algorithm
MIT License
11.67k stars 777 forks source link

Question: HTML string to vTree #439

Closed davidworkman9 closed 7 years ago

davidworkman9 commented 7 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 7 years ago

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

davidworkman9 commented 7 years ago

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