Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jamen/h2dom

Create DOM nodes using h functions
https://github.com/jamen/h2dom

dom dom-node h h2 h2spec html virtual-dom

Last synced: 25 days ago
JSON representation

Create DOM nodes using h functions

Awesome Lists containing this project

README

        

# h2dom

> Create DOM nodes using h functions

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

## Example

```js
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.](https://github.com/hyper2/h2spec)

### `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`