src/html-marker.js
/* update all referenced nodes with the model values */
update all referenced nodes with the model values
update all referenced nodes with the model values
update() {
    this.referenceNodes.forEach(({ isBooleanAttr = false, name = '', node, oldValue = null, value }, reference) => {
      if (node.nodeType === Node.ELEMENT_NODE && !document.body.contains(node)) {
        this.referenceNodes.delete(reference)
      } else {
        let newValue = this._interpolate({ params: this.model, template: value })
        if (!isBooleanAttr && newValue !== oldValue) {
          if (node.nodeType === Node.COMMENT_NODE) {
            const newNode = this._parseHTML(`<span>${newValue}</span>`)
            node.parentNode.replaceChild(newNode, node.nextSibling)
          } else if (node.nodeType === Node.ATTRIBUTE_NODE) {
            if (node.nodeName === 'class') {
              newValue = this._handleClassValue({ node, oldValue, value })
            } else {
              node.value = newValue
            }
          } else if (node.tagName === 'TEXTAREA') {
            node.value = newValue
          }
        }
        if (isBooleanAttr) {
          node.toggleAttribute(name, !!newValue.toString().length)
        }
        reference.oldValue = newValue
      }
    })
    return Promise.resolve(true)
  }
update ( ) { this . referenceNodes . forEach ( ( { isBooleanAttr = false , name = '' , node , oldValue = null , value } , reference ) => { if ( node . nodeType === Node . ELEMENT_NODE && ! document . body . contains ( node ) ) { this . referenceNodes . delete ( reference ) } else { let newValue = this . _interpolate ( { params : this . model , template : value } ) if ( ! isBooleanAttr && newValue !== oldValue ) { if ( node . nodeType === Node . COMMENT_NODE ) { const newNode = this . _parseHTML ( ` ${ newValue } ` ) node . parentNode . replaceChild ( newNode , node . nextSibling ) } else if ( node . nodeType === Node . ATTRIBUTE_NODE ) { if ( node . nodeName === 'class' ) { newValue = this . _handleClassValue ( { node , oldValue , value } ) } else { node . value = newValue } } else if ( node . tagName === 'TEXTAREA' ) { node . value = newValue } } if ( isBooleanAttr ) { node . toggleAttribute ( name , ! ! newValue . toString ( ) . length ) } reference . oldValue = newValue } } ) return Promise . resolve ( true ) }
update all referenced nodes with the model values
update all referenced nodes with the model values
/* textarea is an element node that requires an attribute update */