mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-02 20:17:52 +08:00
custom directive: postupdate -> componentUpdated (ref #3172)
This commit is contained in:
parent
ac15b048fd
commit
7827593972
@ -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')
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user