lib/index.js
function simulacra (obj, def, matchNode) {
  var document = this ? this.document : window.document
  var Node = this ? this.Node : window.Node
  var node, query

  // Before continuing, check if required features are present.
  featureCheck(this || window, features)

  if (obj === null || typeof obj !== 'object' || isArray(obj))
    throw new TypeError('First argument must be a singular object.')

  if (!isArray(def))
    throw new TypeError('Second argument must be an array.')

  if (typeof def[0] === 'string') {
    query = def[0]
    def[0] = document.querySelector(query)
    if (!def[0]) throw new Error(
      'Top-level Node "' + query + '" could not be found in the document.')
  }
  else if (!(def[0] instanceof Node)) throw new TypeError(
    'The first position of the top-level must be either a Node or a CSS ' +
    'selector string.')

  if (!def[isProcessedKey]) {
    // Auto-detect template tag.
    if ('content' in def[0]) def[0] = def[0].content

    def[0] = def[0].cloneNode(true)
    cleanNode(this, def[0])
    ensureNodes(def[0], def[1])
    setProperties(def)
  }

  node = processNodes(this, def[0], def[1])

  bindKeys(this, obj, def[1], node, { root: obj })

  if (matchNode) {
    rehydrate(this, obj, def[1], node, matchNode)
    return matchNode
  }

  return node
}
function simulacra (obj, def, matchNode) {
  var document = this ? this.document : window.document
  var Node = this ? this.Node : window.Node
  var node, query

  // Before continuing, check if required features are present.
  featureCheck(this || window, features)

  if (obj === null || typeof obj !== 'object' || isArray(obj))
    throw new TypeError('First argument must be a singular object.')

  if (!isArray(def))
    throw new TypeError('Second argument must be an array.')

  if (typeof def[0] === 'string') {
    query = def[0]
    def[0] = document.querySelector(query)
    if (!def[0]) throw new Error(
      'Top-level Node "' + query + '" could not be found in the document.')
  }
  else if (!(def[0] instanceof Node)) throw new TypeError(
    'The first position of the top-level must be either a Node or a CSS ' +
    'selector string.')

  if (!def[isProcessedKey]) {
    // Auto-detect template tag.
    if ('content' in def[0]) def[0] = def[0].content

    def[0] = def[0].cloneNode(true)
    cleanNode(this, def[0])
    ensureNodes(def[0], def[1])
    setProperties(def)
  }

  node = processNodes(this, def[0], def[1])

  bindKeys(this, obj, def[1], node, { root: obj })

  if (matchNode) {
    rehydrate(this, obj, def[1], node, matchNode)
    return matchNode
  }

  return node
}
function simulacra ( obj , def , matchNode ) { var document = this ? this . document : window . document var Node = this ? this . Node : window . Node var node , query // Before continuing, check if required features are present. featureCheck ( this || window , features ) if ( obj === null || typeof obj !== 'object' || isArray ( obj ) ) throw new TypeError ( 'First argument must be a singular object.' ) if ( ! isArray ( def ) ) throw new TypeError ( 'Second argument must be an array.' ) if ( typeof def [ 0 ] === 'string' ) { query = def [ 0 ] def [ 0 ] = document . querySelector ( query ) if ( ! def [ 0 ] ) throw new Error ( 'Top-level Node "' + query + '" could not be found in the document.' ) } else if ( ! ( def [ 0 ] instanceof Node ) ) throw new TypeError ( 'The first position of the top-level must be either a Node or a CSS ' + 'selector string.' ) if ( ! def [ isProcessedKey ] ) { // Auto-detect template tag. if ( 'content' in def [ 0 ] ) def [ 0 ] = def [ 0 ] . content def [ 0 ] = def [ 0 ] . cloneNode ( true ) cleanNode ( this , def [ 0 ] ) ensureNodes ( def [ 0 ] , def [ 1 ] ) setProperties ( def ) } node = processNodes ( this , def [ 0 ] , def [ 1 ] ) bindKeys ( this , obj , def [ 1 ] , node , { root : obj } ) if ( matchNode ) { rehydrate ( this , obj , def [ 1 ] , node , matchNode ) return matchNode } return node }
Bind an object to the DOM.

@param {Object} obj
@param {Object} def
@param {Node} [matchNode]
@return {Node}
Bind an object to the DOM .