Sha256: 1b25d3e4df7088bba8b5f08706875d7c4a1b83deaf276a16eb86999aad1231c0

Contents?: true

Size: 969 Bytes

Versions: 5

Compression:

Stored size: 969 Bytes

Contents

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

module.exports = {

  isLiteral: true,

  // same logic reuse from v-if
  compile: vIf.compile,
  teardown: vIf.teardown,

  bind: function () {
    var el = this.el
    this.start = document.createComment('v-partial-start')
    this.end = document.createComment('v-partial-end')
    if (el.nodeType !== 8) {
      el.innerHTML = ''
    }
    if (el.tagName === 'TEMPLATE' || el.nodeType === 8) {
      _.replace(el, this.end)
    } else {
      el.appendChild(this.end)
    }
    _.before(this.start, this.end)
    if (!this._isDynamicLiteral) {
      this.insert(this.expression)
    }
  },

  update: function (id) {
    this.teardown()
    this.insert(id)
  },

  insert: function (id) {
    var partial = this.vm.$options.partials[id]
    _.assertAsset(partial, 'partial', id)
    if (partial) {
      this.compile(templateParser.parse(partial))
    }
  }

}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fluentd-ui-0.3.13 vendor/assets/javascripts/bower/vue/src/directives/partial.js
fluentd-ui-0.3.12 vendor/assets/javascripts/bower/vue/src/directives/partial.js
fluentd-ui-0.3.11 vendor/assets/javascripts/bower/vue/src/directives/partial.js
fluentd-ui-0.3.10 vendor/assets/javascripts/bower/vue/src/directives/partial.js
fluentd-ui-0.3.9 vendor/assets/javascripts/bower/vue/src/directives/partial.js