Ask HN: Why do VDOM implementations always use function calls instead of data?

https://news.ycombinator.com/item?id=31299715
by brundolf • 4 years ago
6 3 4 years ago

Example from Mithril.js:

  m("main", [
    m("h1", {class: "title"}, "My first app"),
    m("button", "A button"),
  ])
React does the same (after the JSX is compiled), and I'm not aware of any that don't use function calls, vs just plain object data:
  {
    tag: "main",
    children: [
      { tag: "h1", attributes: { class: "title" }, children: [ "My first app" ] },
      { tag: "button", children: [ "A button" ] }
    ]
  }
Is it just for brevity, or is there some deeper reason I'm missing?

Related Stories

Loading related stories...

Source preview

news.ycombinator.com