lib/element.js
function Element (tagName, props, children) {
  if (!(this instanceof Element)) {
    if (!_.isArray(children) && children != null) {
      children = _.slice(arguments, 2).filter(_.truthy)
    }
    return new Element(tagName, props, children)
  }

  if (_.isArray(props)) {
    children = props
    props = {}
  }

  this.tagName = tagName
  this.props = props || {}
  this.children = children || []
  this.key = props
    ? props.key
    : void 666

  var count = 0

  _.each(this.children, function (child, i) {
    if (child instanceof Element) {
      count += child.count
    } else {
      children[i] = '' + child
    }
    count++
  })

  this.count = count
}
function Element (tagName, props, children) {
  if (!(this instanceof Element)) {
    if (!_.isArray(children) && children != null) {
      children = _.slice(arguments, 2).filter(_.truthy)
    }
    return new Element(tagName, props, children)
  }

  if (_.isArray(props)) {
    children = props
    props = {}
  }

  this.tagName = tagName
  this.props = props || {}
  this.children = children || []
  this.key = props
    ? props.key
    : void 666

  var count = 0

  _.each(this.children, function (child, i) {
    if (child instanceof Element) {
      count += child.count
    } else {
      children[i] = '' + child
    }
    count++
  })

  this.count = count
}
function Element ( tagName , props , children ) { if ( ! ( this instanceof Element ) ) { if ( ! _ . isArray ( children ) && children != null ) { children = _ . slice ( arguments , 2 ) . filter ( _ . truthy ) } return new Element ( tagName , props , children ) } if ( _ . isArray ( props ) ) { children = props props = { } } this . tagName = tagName this . props = props || { } this . children = children || [ ] this . key = props ? props . key : void 666 var count = 0 _ . each ( this . children , function ( child , i ) { if ( child instanceof Element ) { count += child . count } else { children [ i ] = '' + child } count ++ } ) this . count = count }
Virtual-dom Element.
@param {String} tagName
@param {Object} props - Element's properties,
- using object to store key-value pair
@param {Array<Element|String>} - This element's children elements.
- Can be Element instance or just a piece plain text.
Virtual - dom Element .