spec/uglify/riot.js
function update(expressions, tag) {

  each(expressions, function(expr, i) {

    var dom = expr.dom,
      attrName = expr.attr,
      value = tmpl(expr.expr, tag),
      parent = expr.dom.parentNode

    if (expr.bool)
      value = value ? attrName : false
    else if (value == null)
      value = ''

    // leave out riot- prefixes from strings inside textarea
    // fix #815: any value -> string
    if (parent && parent.tagName == 'TEXTAREA') {
      value = ('' + value).replace(/riot-/g, '')
      // change textarea's value
      parent.value = value
    }

    // no change
    if (expr.value === value) return
    expr.value = value

    // text node
    if (!attrName) {
      dom.nodeValue = '' + value    // #815 related
      return
    }

    // remove original attribute
    remAttr(dom, attrName)
    // event handler
    if (isFunction(value)) {
      setEventHandler(attrName, value, dom, tag)

    // if- conditional
    } else if (attrName == 'if') {
      var stub = expr.stub,
        add = function() { insertTo(stub.parentNode, stub, dom) },
        remove = function() { insertTo(dom.parentNode, dom, stub) }

      // add to DOM
      if (value) {
        if (stub) {
          add()
          dom.inStub = false
          // avoid to trigger the mount event if the tags is not visible yet
          // maybe we can optimize this avoiding to mount the tag at all
          if (!isInStub(dom)) {
            walk(dom, function(el) {
              if (el._tag && !el._tag.isMounted)
                el._tag.isMounted = !!el._tag.trigger('mount')
            })
          }
        }
      // remove from DOM
      } else {
        stub = expr.stub = stub || document.createTextNode('')
        // if the parentNode is defined we can easily replace the tag
        if (dom.parentNode)
          remove()
        // otherwise we need to wait the updated event
        else (tag.parent || tag).one('updated', remove)

        dom.inStub = true
      }
    // show / hide
    } else if (/^(show|hide)$/.test(attrName)) {
      if (attrName == 'hide') value = !value
      dom.style.display = value ? '' : 'none'

    // field value
    } else if (attrName == 'value') {
      dom.value = value

    // <img src="{ expr }">
    } else if (startsWith(attrName, RIOT_PREFIX) && attrName != RIOT_TAG) {
      if (value)
        setAttr(dom, attrName.slice(RIOT_PREFIX.length), value)

    } else {
      if (expr.bool) {
        dom[attrName] = value
        if (!value) return
      }

      if (value === 0 || value && typeof value !== T_OBJECT)
        setAttr(dom, attrName, value)

    }

  })

}
function update(expressions, tag) {

  each(expressions, function(expr, i) {

    var dom = expr.dom,
      attrName = expr.attr,
      value = tmpl(expr.expr, tag),
      parent = expr.dom.parentNode

    if (expr.bool)
      value = value ? attrName : false
    else if (value == null)
      value = ''

    // leave out riot- prefixes from strings inside textarea
    // fix #815: any value -> string
    if (parent && parent.tagName == 'TEXTAREA') {
      value = ('' + value).replace(/riot-/g, '')
      // change textarea's value
      parent.value = value
    }

    // no change
    if (expr.value === value) return
    expr.value = value

    // text node
    if (!attrName) {
      dom.nodeValue = '' + value    // #815 related
      return
    }

    // remove original attribute
    remAttr(dom, attrName)
    // event handler
    if (isFunction(value)) {
      setEventHandler(attrName, value, dom, tag)

    // if- conditional
    } else if (attrName == 'if') {
      var stub = expr.stub,
        add = function() { insertTo(stub.parentNode, stub, dom) },
        remove = function() { insertTo(dom.parentNode, dom, stub) }

      // add to DOM
      if (value) {
        if (stub) {
          add()
          dom.inStub = false
          // avoid to trigger the mount event if the tags is not visible yet
          // maybe we can optimize this avoiding to mount the tag at all
          if (!isInStub(dom)) {
            walk(dom, function(el) {
              if (el._tag && !el._tag.isMounted)
                el._tag.isMounted = !!el._tag.trigger('mount')
            })
          }
        }
      // remove from DOM
      } else {
        stub = expr.stub = stub || document.createTextNode('')
        // if the parentNode is defined we can easily replace the tag
        if (dom.parentNode)
          remove()
        // otherwise we need to wait the updated event
        else (tag.parent || tag).one('updated', remove)

        dom.inStub = true
      }
    // show / hide
    } else if (/^(show|hide)$/.test(attrName)) {
      if (attrName == 'hide') value = !value
      dom.style.display = value ? '' : 'none'

    // field value
    } else if (attrName == 'value') {
      dom.value = value

    // <img src="{ expr }">
    } else if (startsWith(attrName, RIOT_PREFIX) && attrName != RIOT_TAG) {
      if (value)
        setAttr(dom, attrName.slice(RIOT_PREFIX.length), value)

    } else {
      if (expr.bool) {
        dom[attrName] = value
        if (!value) return
      }

      if (value === 0 || value && typeof value !== T_OBJECT)
        setAttr(dom, attrName, value)

    }

  })

}
function update ( expressions , tag ) { each ( expressions , function ( expr , i ) { var dom = expr . dom , attrName = expr . attr , value = tmpl ( expr . expr , tag ) , parent = expr . dom . parentNode if ( expr . bool ) value = value ? attrName : false else if ( value == null ) value = '' // leave out riot- prefixes from strings inside textarea // fix #815: any value -> string if ( parent && parent . tagName == 'TEXTAREA' ) { value = ( '' + value ) . replace ( / riot- / g , '' ) // change textarea's value parent . value = value } // no change if ( expr . value === value ) return expr . value = value // text node if ( ! attrName ) { dom . nodeValue = '' + value // #815 related return } // remove original attribute remAttr ( dom , attrName ) // event handler if ( isFunction ( value ) ) { setEventHandler ( attrName , value , dom , tag ) // if- conditional } else if ( attrName == 'if' ) { var stub = expr . stub , add = function ( ) { insertTo ( stub . parentNode , stub , dom ) } , remove = function ( ) { insertTo ( dom . parentNode , dom , stub ) } // add to DOM if ( value ) { if ( stub ) { add ( ) dom . inStub = false // avoid to trigger the mount event if the tags is not visible yet // maybe we can optimize this avoiding to mount the tag at all if ( ! isInStub ( dom ) ) { walk ( dom , function ( el ) { if ( el . _tag && ! el . _tag . isMounted ) el . _tag . isMounted = ! ! el . _tag . trigger ( 'mount' ) } ) } } // remove from DOM } else { stub = expr . stub = stub || document . createTextNode ( '' ) // if the parentNode is defined we can easily replace the tag if ( dom . parentNode ) remove ( ) // otherwise we need to wait the updated event else ( tag . parent || tag ) . one ( 'updated' , remove ) dom . inStub = true } // show / hide } else if ( / ^(show|hide)$ / . test ( attrName ) ) { if ( attrName == 'hide' ) value = ! value dom . style . display = value ? '' : 'none' // field value } else if ( attrName == 'value' ) { dom . value = value // <img src="{ expr }"> } else if ( startsWith ( attrName , RIOT_PREFIX ) && attrName != RIOT_TAG ) { if ( value ) setAttr ( dom , attrName . slice ( RIOT_PREFIX . length ) , value ) } else { if ( expr . bool ) { dom [ attrName ] = value if ( ! value ) return } if ( value === 0 || value && typeof value !== T_OBJECT ) setAttr ( dom , attrName , value ) } } ) }
Update the expressions in a Tag instance
@param   { Array } expressions - expression that must be re evaluated
@param   { Tag } tag - tag instance
Update the expressions in a Tag instance