Skip to content

znck/html-to-vnode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML to VDOM

Convert HTML to VDOM tree.

Example

node test.js

Input

<h1>Tasks</h1>

<ul>
  <li>
    <input type="checkbox" id="task1" />
    <label for="task1">Buy milk</label>
  </li>
  <li>
    <input type="checkbox" id="task2" />
    <label for="task2">Buy eggs</label>
  </li>
  <li>
    <input type="checkbox" id="task2" />
    <label for="task2">Make omelette</label>
  </li>
</ul>

Output

export function render() {
  return [
    h("h1", {}, ["Tasks"]),
    h("ul", {}, [
      h("li", {}, [
        h("input", {
          type: "checkbox",
          id: "task1"
        }, []),
        h("label", { for: "task1" }, ["Buy milk"])
      ]),
      h("li", {}, [
        h("input", {
          type: "checkbox",
          id: "task2"
        }, []),
        h("label", { for: "task2" }, ["Buy eggs"])
      ]),
      h("li", {}, [
        h("input", {
          type: "checkbox",
          id: "task2"
        }, []),
        h("label", { for: "task2" }, ["Make omelette"])
      ])
    ])
  ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published