unified

Project:syntax-tree/hast-util-to-snabbdom

Package:hast-util-to-snabbdom@1.0.2

  1. Dependencies:2·Dependents:1
  2. hast utility to transform to a Snabbdom tree
  1. util 105
  2. utility 105
  3. html 100
  4. unist 90
  5. hast 51
  6. hast-util 40
  7. tree 40
  8. ast 27
  9. virtual 21
  10. dom 9
  11. vdom 5

hast-util-to-snabbdom

Build Coverage Downloads Size Sponsors Backers Chat

hast utility to transform to Snabbdom.

Install

npm:

npm install hast-util-to-snabbdom

Use

const u = require('unist-builder')
const h = require('hastscript')
const toSnabbdom = require('hast-util-to-snabbdom')

const hast = h('form', {id: 'a', className: ['b', 'c']}, [
  'hey there!',
  u('comment', 'i am a comment'),
  h('input', {type: 'file'})
])

console.dir(toSnabbdom(hast))
{ sel: 'form',
  data: { attrs: { id: 'a', class: 'b c' } },
  children:
   [ { sel: undefined,
       data: undefined,
       children: undefined,
       text: 'hey there!',
       elm: undefined,
       key: undefined },
     { sel: 'input',
       data: { attrs: { type: 'file' } },
       children: [],
       text: undefined,
       elm: undefined,
       key: undefined } ],
  text: undefined,
  elm: undefined,
  key: undefined }

API

toSnabbdom(tree)

Transform the given hast tree to a Snabbdom tree.

Parameters
Returns

A Snabbdom node.

Security

Use of hast-util-to-snabbdom can open you up to a cross-site scripting (XSS) attack if the hast tree is unsafe. Use hast-util-santize to make the hast tree safe.

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

ISC © Jannis Redmann