module.exports = {
  server: server,
  client: client
}

var escapeTextForBrowser = require('react/lib/escapeTextForBrowser')

function server(html, data = {}, meta = {}) {
  var xState = escapeTextForBrowser(JSON.stringify(data))
  var xMeta = escapeTextForBrowser(JSON.stringify(meta))

  return (
`<div class="node-iso-v3"
      data-state="${xState}"
      data-meta="${xMeta}">
  ${html}
</div>`
  )
}

function client(cb) {
  Array.prototype.forEach.call(
    document.querySelectorAll('.node-iso-v3'),
    node => cb(JSON.parse(node.dataset.state), JSON.parse(node.dataset.meta), node)
  )
}

module.exports = {
  server: server,
  client: client
}

var escapeTextForBrowser = require('react/lib/escapeTextForBrowser')

function server(html, data = {}, meta = {}) {
  var xState = escapeTextForBrowser(JSON.stringify(data))
  var xMeta = escapeTextForBrowser(JSON.stringify(meta))

  return (
`<div class="node-iso-v3"
      data-state="${xState}"
      data-meta="${xMeta}">
  ${html}
</div>`
  )
}

function client(cb) {
  Array.prototype.forEach.call(
    document.querySelectorAll('.node-iso-v3'),
    node => cb(JSON.parse(node.getAttribute('data-state')), JSON.parse(node.getAttribute('data-meta')), node)
  )
}

Use Element.getAttribute instead of `node.dataset`
Use Element.getAttribute instead of `node.dataset`

This is more compatible with older browsers and makes it easier to use a
transpiler without requiring polyfills.
