Sha256: 5e13c38637573db8e06d3e46cc2b6ca5eb6e4cf51284532a90520a20bcfc819a

Contents?: true

Size: 1017 Bytes

Versions: 6

Compression:

Stored size: 1017 Bytes

Contents

var _ = require('../util')
var templateParser = require('../parsers/template')

module.exports = {

  bind: function () {
    // a comment node means this is a binding for
    // {{{ inline unescaped html }}}
    if (this.el.nodeType === 8) {
      // hold nodes
      this.nodes = []
      // replace the placeholder with proper anchor
      this.anchor = _.createAnchor('v-html')
      _.replace(this.el, this.anchor)
    }
  },

  update: function (value) {
    value = _.toString(value)
    if (this.nodes) {
      this.swap(value)
    } else {
      this.el.innerHTML = value
    }
  },

  swap: function (value) {
    // remove old nodes
    var i = this.nodes.length
    while (i--) {
      _.remove(this.nodes[i])
    }
    // convert new value to a fragment
    // do not attempt to retrieve from id selector
    var frag = templateParser.parse(value, true, true)
    // save a reference to these nodes so we can remove later
    this.nodes = _.toArray(frag.childNodes)
    _.before(frag, this.anchor)
  }
}

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
statixite-1.0.2 vendor/assets/bower_components/vue/src/directives/html.js
statixite-1.0.1 vendor/assets/bower_components/vue/src/directives/html.js
statixite-1.0.0 vendor/assets/bower_components/vue/src/directives/html.js
plate-lang-0.1.2 skeleton/vendor/vue/src/directives/html.js
plate-lang-0.1.1 skeleton/vendor/vue/src/directives/html.js
plate-lang-0.1.0 skeleton/vendor/vue/src/directives/html.js