Evan You 11 лет назад
Родитель
Сommit
dc745af66b
4 измененных файлов с 8 добавлено и 17 удалено
  1. 1 2
      src/directives/component.js
  2. 1 2
      src/directives/if.js
  3. 1 2
      src/directives/repeat.js
  4. 5 11
      src/directives/with.js

+ 1 - 2
src/directives/component.js

@@ -134,8 +134,7 @@ module.exports = {
     if (this.Ctor && !this.childVM) {
       this.childVM = this.vm._addChild({
         el: this.el.cloneNode(true),
-        parent: this.vm,
-        _noSync: true
+        parent: this.vm
       }, this.Ctor)
       if (this.keepAlive) {
         this.cache[this.id] = this.childVM

+ 1 - 2
src/directives/if.js

@@ -41,8 +41,7 @@ module.exports = {
     this.childVM = this.vm._addChild({
       el: this.el,
       parent: this.vm,
-      anonymous: true,
-      _noSync: true
+      anonymous: true
     })
   },
 

+ 1 - 2
src/directives/repeat.js

@@ -237,8 +237,7 @@ module.exports = {
     var vm = this.vm._addChild({
       el: this.el.cloneNode(true),
       data: data,
-      parent: this.vm,
-      _noSync: hasAlias
+      parent: this.vm
     }, Ctor)
     // define alias
     if (hasAlias && !alias) {

+ 5 - 11
src/directives/with.js

@@ -5,18 +5,12 @@ module.exports = {
   priority: 900,
 
   bind: function () {
-    if (!this.arg) {
-      // by default, components have _noSync:true
-      // but when there's no arg it means we are
-      // inheriting a parent object as $data, so we have
-      // to sync the chagnes
-      this.vm.$options._noSync = false
+    if (this.arg) {
+      var self = this
+      this.vm.$watch(this.arg, function (val) {
+        self.set(_.toNumber(val))
+      })
     }
-    var self = this
-    var path = this.arg || '$data'
-    this.vm.$watch(path, function (val) {
-      self.set(_.toNumber(val))
-    })
   },
 
   update: function (value) {