Просмотр исходного кода

props do not need to be in sync mode

Evan You 11 лет назад
Родитель
Сommit
eabca4d8de
3 измененных файлов с 14 добавлено и 14 удалено
  1. 2 4
      src/directives/prop.js
  2. 1 3
      src/watcher.js
  3. 11 7
      test/unit/specs/instance/scope_spec.js

+ 2 - 4
src/directives/prop.js

@@ -30,8 +30,7 @@ module.exports = {
           }
           locked = false
         }
-      },
-      { sync: true }
+      }
     )
     
     // set the child initial value first, before setting
@@ -54,8 +53,7 @@ module.exports = {
             parent.$set(parentKey, val)
             locked = false
           }
-        },
-        { sync: true }
+        }
       )
     }
   },

+ 1 - 3
src/watcher.js

@@ -18,7 +18,6 @@ var uid = 0
  *                 - {Boolean} twoWay
  *                 - {Boolean} deep
  *                 - {Boolean} user
- *                 - {Boolean} sync
  *                 - {Function} [preProcess]
  * @constructor
  */
@@ -35,7 +34,6 @@ function Watcher (vm, expOrFn, cb, options) {
   this.deep = !!options.deep
   this.user = !!options.user
   this.twoWay = !!options.twoWay
-  this.sync = !!options.sync
   this.filters = options.filters
   this.preProcess = options.preProcess
   this.deps = []
@@ -162,7 +160,7 @@ p.afterGet = function () {
  */
 
 p.update = function () {
-  if (this.sync || !config.async) {
+  if (!config.async) {
     this.run()
   } else {
     batcher.push(this)

+ 11 - 7
test/unit/specs/instance/scope_spec.js

@@ -56,7 +56,7 @@ describe('Instance Scope', function () {
       expect(vm.hasOwnProperty('a')).toBe(false)
     })
 
-    it('replace $data and handle props', function () {
+    it('replace $data and handle props', function (done) {
       var el = document.createElement('div')
       var vm = new Vue({
         el: el,
@@ -95,15 +95,19 @@ describe('Instance Scope', function () {
         b: 3, // one-time
         c: 4  // two-way
       }
-      // one-way
       expect(child.a).toBe(2)
-      expect(vm.a).toBe(1)
-      // one-time
       expect(child.b).toBe(3)
-      expect(vm.b).toBe(2)
-      // two-way
       expect(child.c).toBe(4)
-      expect(vm.c).toBe(4)
+      // assert parent state
+      Vue.nextTick(function () {
+        // one-way
+        expect(vm.a).toBe(1)
+        // one-time
+        expect(vm.b).toBe(2)
+        // two-way
+        expect(vm.c).toBe(4)
+        done()
+      })
     })
 
   })