0.2.7 • Published 7 years ago

@mojule/h v0.2.7

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

h

API for creating DOM nodes, like hyperscript

npm install @mojule/h

const H = require( '@mojule/h' )

// window.document, JSDOM document instance, etc
const h = H( document )

const { element, textNode, comment, documentFragment, div, p } = h

const dom = div(
  p(
    {
      id: 'foo',
      click: e => console.log( 'clicked #foo' ),
      data: {
        fooBar: 'baz'
      },
      style: {
        fontSize: '16px',
        'font-weight': 'bold'
      }
    },
    documentFragment(
      element( 'custom-tag', 'hello' ),
      // text node as string literal
      ' ',
      // or explicitly
      textNode( 'world' ),
      comment( 'bar' )
    )
  )
)

// <p id="foo" data-foo-bar="baz" style="font-size: 16px; font-weight: bold;"><custom-tag>hello</custom-tag> world<!--bar--></p>
console.log( dom.innerHTML )
0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago