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

This commit is contained in:
Evan You 2016-06-29 21:32:02 -04:00
parent ac15b048fd
commit 7827593972
3 changed files with 8 additions and 8 deletions

View File

@ -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')

View File

@ -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)

View File

@ -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()