Kaynağa Gözat

always set props even if value is the same

Evan You 10 yıl önce
ebeveyn
işleme
22d7acba03

+ 1 - 2
src/platforms/web/runtime/modules/props.js

@@ -16,7 +16,6 @@ function updateProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
   }
   for (key in props) {
     cur = props[key]
-    old = oldProps[key]
     if (key === 'value') {
       // store value as _value as well since
       // non-string values will be stringified
@@ -25,7 +24,7 @@ function updateProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
       if (elm.value != cur) { // eslint-disable-line
         elm.value = cur
       }
-    } else if (old !== cur) {
+    } else {
       elm[key] = cur
     }
   }

+ 3 - 6
test/unit/features/directives/model-checkbox.spec.js

@@ -39,9 +39,8 @@ describe('Directive v-model checkbox', () => {
     vm.$el.click()
     expect(vm.$el.checked).toBe(true)
     expect(vm.test).toBe(1)
+    vm.test = 2
     waitForUpdate(() => {
-      vm.test = 2
-    }).then(() => {
       expect(vm.$el.checked).toBe(false)
       vm.test = 1
     }).then(() => {
@@ -71,9 +70,8 @@ describe('Directive v-model checkbox', () => {
     expect(vm.test).toEqual(['2'])
     vm.$el.children[0].click()
     expect(vm.test).toEqual(['2', '1'])
+    vm.test = ['1']
     waitForUpdate(() => {
-      vm.test = ['1']
-    }).then(() => {
       expect(vm.$el.children[0].checked).toBe(true)
       expect(vm.$el.children[1].checked).toBe(false)
     }).then(done)
@@ -100,9 +98,8 @@ describe('Directive v-model checkbox', () => {
     expect(vm.test).toEqual([2])
     vm.$el.children[0].click()
     expect(vm.test).toEqual([2, 1])
+    vm.test = [1]
     waitForUpdate(() => {
-      vm.test = [1]
-    }).then(() => {
       expect(vm.$el.children[0].checked).toBe(true)
       expect(vm.$el.children[1].checked).toBe(false)
     }).then(done)