Esempio n. 1
0
 var x = hyperx(function x (tag, props, children) {
   var el
   var name
   var value
   if (components.hasOwnProperty(tag)) {
     // create a placeholder for a component
     el = bel.createElement('co-' + tag.toLowerCase(), {}, [])
     // I'm not sure why hyperx stringifies numbers and bools, but let's undo it
     for (name in props) {
       value = props[name]
       var numValue
       if (typeof value === 'string') {
         if (value === 'true') {
           props[name] = true
         } else if (value === 'false') {
           props[name] = false
         } else if (value !== '') {
           numValue = Number(value)
           if (!isNaN(numValue)) {
             props[name] = numValue
           }
         }
       }
     }
     el._co = {
       component: tag,
       props: props
     }
     if (children && children.length) {
       el._co.props.children = children
     }
   } else {
     // regular node. construct with bel
     var elProps = {}
     var events = {}
     for (name in props) {
       value = props[name]
       if (name.slice(0, 2) === 'on') {
         name = name.toLowerCase()
         events[name] = value
       }
       elProps[name] = value
     }
     el = bel.createElement(tag, elProps, children)
     el._co = {
       events: events
     }
   }
   return el
 })
Esempio n. 2
0
 x.render = function render (element, container) {
   var toContainer = bel.createElement('div', {}, [element])
   update(container, toContainer, false)
 }
Esempio n. 3
0
const cxsCreateElement = (tag, props, children) => {
  if (props.className && typeof props.className === 'object') {
    props.className = cxs(props.className)
  }
  return createElement(tag, props, children)
}