Skip to content

jamen/h2dom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

h2dom

Create DOM nodes using h functions

NOTICE This is not a patch function, it simply creates DOM nodes.

Example

var node = h('div', { class: 'foo' }, [
  h('span', null, 'foo'),
  ' bar'
])

document.body.appendChild(node)

Install

npm i h2dom

Usage

This function follows the h2spec guidelines.

h(tag, data?, children?)

  • tag: the element name passed to document.createElement(name)
  • data (optional): an object containing the attributes to set on the element
  • children (optional): an array of DOM nodes or primitive values to be listed under element.childNodes