Sha256: c732a5b6f88f1851cfb02948dd6a1d246e376d6a91c2b4fcb1abd3ad11e0ffd9

Contents?: true

Size: 922 Bytes

Versions: 5

Compression:

Stored size: 922 Bytes

Contents

var _ = require('../util')
var Watcher = require('../watcher')

module.exports = {

  priority: 900,

  bind: function () {
    var vm = this.vm
    if (this.el !== vm.$el) {
      _.warn(
        'v-with can only be used on instance root elements.'
      )
    } else if (!vm.$parent) {
      _.warn(
        'v-with must be used on an instance with a parent.'
      )
    } else {
      var key = this.arg
      this.watcher = new Watcher(
        vm.$parent,
        this.expression,
        key
          ? function (val) {
              vm.$set(key, val)
            }
          : function (val) {
              vm.$data = val
            }
      )
      // initial set
      var initialVal = this.watcher.value
      if (key) {
        vm.$set(key, initialVal)
      } else {
        vm.$data = initialVal
      }
    }
  },

  unbind: function () {
    if (this.watcher) {
      this.watcher.teardown()
    }
  }

}

Version data entries

5 entries across 5 versions & 1 rubygems

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