1.0.0 • Published 7 years ago

hyperx-snabbdom v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

This module is a fork of hyperx-to-snabbdom extended with a fix for whitespace inconsistency.

The module itself converts hyperx virtual dom build to a snabbdom-compatible output.

Usage:

npm i --save hyperx hyperx-snabbdom snabbdom

// patch.js

var snabbdom = require('snabbdom')
module.exports = snabbdom.init([ // Init patch function with chosen modules
  require('snabbdom/modules/class').default, // makes it easy to toggle classes
  require('snabbdom/modules/props').default, // for setting properties on DOM elements
  require('snabbdom/modules/style').default, // handles styling on elements with support for animations
  require('snabbdom/modules/eventlisteners').default // attaches event listeners
])

// html.js 

module.exports = require('hyperx')(
  require('hyperx-to-snabbdom')(require('snabbdom/h').default)
)

// my-module.js

var patch = require('./patch')
var html = require('./html')

function homeView () {
  return html`
    <body>
      <h1>Home view</h1>
    </body>
  `
}

patch(document.body, homeView())