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

custom directive: postupdate -> componentUpdated (ref #3172)

Evan You 10 лет назад
Родитель
Сommit
7827593972

+ 1 - 1
src/core/vdom/modules/directives.js

@@ -10,7 +10,7 @@ export default {
     applyDirectives(oldVnode, vnode, 'update')
   },
   postpatch: function postupdateDirectives (oldVnode: VNodeWithData, vnode: VNodeWithData) {
-    applyDirectives(oldVnode, vnode, 'postupdate')
+    applyDirectives(oldVnode, vnode, 'componentUpdated')
   },
   destroy: function unbindDirectives (vnode: VNodeWithData) {
     applyDirectives(vnode, vnode, 'unbind')

+ 1 - 1
src/platforms/web/runtime/directives/model.js

@@ -44,7 +44,7 @@ export default {
       }
     }
   },
-  postupdate (el, binding, vnode) {
+  componentUpdated (el, binding, vnode) {
     const val = binding.value
     if (vnode.tag === 'select') {
       setSelected(el, val)

+ 6 - 6
test/unit/features/options/directives.spec.js

@@ -4,7 +4,7 @@ describe('Options directives', () => {
   it('basic usage', done => {
     const bindSpy = jasmine.createSpy('bind')
     const updateSpy = jasmine.createSpy('update')
-    const postupdateSpy = jasmine.createSpy('postupdate')
+    const componentUpdatedSpy = jasmine.createSpy('componentUpdated')
     const unbindSpy = jasmine.createSpy('unbind')
 
     const assertContext = (el, binding, vnode) => {
@@ -39,8 +39,8 @@ describe('Options directives', () => {
             expect(binding.oldValue).toBe('foo')
             expect(binding.expression).toBe('a')
           },
-          postupdate (el, binding, vnode) {
-            postupdateSpy()
+          componentUpdated (el, binding, vnode) {
+            componentUpdatedSpy()
             assertContext(el, binding, vnode)
           },
           unbind (el, binding, vnode) {
@@ -54,16 +54,16 @@ describe('Options directives', () => {
     vm.$mount()
     expect(bindSpy).toHaveBeenCalled()
     expect(updateSpy).not.toHaveBeenCalled()
-    expect(postupdateSpy).not.toHaveBeenCalled()
+    expect(componentUpdatedSpy).not.toHaveBeenCalled()
     expect(unbindSpy).not.toHaveBeenCalled()
     vm.a = 'bar'
     waitForUpdate(() => {
       expect(updateSpy).toHaveBeenCalled()
-      expect(postupdateSpy).toHaveBeenCalled()
+      expect(componentUpdatedSpy).toHaveBeenCalled()
       expect(unbindSpy).not.toHaveBeenCalled()
       vm.msg = 'bye'
     }).then(() => {
-      expect(postupdateSpy.calls.count()).toBe(2)
+      expect(componentUpdatedSpy.calls.count()).toBe(2)
       vm.ok = false
     }).then(() => {
       expect(unbindSpy).toHaveBeenCalled()