diff --git a/src/core/vdom/helpers/merge-hook.js b/src/core/vdom/helpers/merge-hook.js index 2312d92a..0bb96e8b 100644 --- a/src/core/vdom/helpers/merge-hook.js +++ b/src/core/vdom/helpers/merge-hook.js @@ -1,9 +1,13 @@ /* @flow */ +import VNode from '../vnode' import { createFnInvoker } from './update-listeners' import { remove, isDef, isUndef, isTrue } from 'shared/util' export function mergeVNodeHook (def: Object, hookKey: string, hook: Function) { + if (def instanceof VNode) { + def = def.data.hook || (def.data.hook = {}) + } let invoker const oldHook = def[hookKey] diff --git a/src/core/vdom/modules/directives.js b/src/core/vdom/modules/directives.js index db35c354..42e33f9e 100644 --- a/src/core/vdom/modules/directives.js +++ b/src/core/vdom/modules/directives.js @@ -54,14 +54,14 @@ function _update (oldVnode, vnode) { } } if (isCreate) { - mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert) + mergeVNodeHook(vnode, 'insert', callInsert) } else { callInsert() } } if (dirsWithPostpatch.length) { - mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', () => { + mergeVNodeHook(vnode, 'postpatch', () => { for (let i = 0; i < dirsWithPostpatch.length; i++) { callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode) } diff --git a/src/platforms/web/runtime/directives/model.js b/src/platforms/web/runtime/directives/model.js index 2f625739..c3b669f3 100644 --- a/src/platforms/web/runtime/directives/model.js +++ b/src/platforms/web/runtime/directives/model.js @@ -24,7 +24,7 @@ const directive = { if (vnode.tag === 'select') { // #6903 if (oldVnode.elm && !oldVnode.elm._vOptions) { - mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', () => { + mergeVNodeHook(vnode, 'postpatch', () => { directive.componentUpdated(el, binding, vnode) }) } else { diff --git a/src/platforms/web/runtime/modules/transition.js b/src/platforms/web/runtime/modules/transition.js index 94acb90d..9ff1c1d2 100644 --- a/src/platforms/web/runtime/modules/transition.js +++ b/src/platforms/web/runtime/modules/transition.js @@ -130,7 +130,7 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) { if (!vnode.data.show) { // remove pending leave element on enter by injecting an insert hook - mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', () => { + mergeVNodeHook(vnode, 'insert', () => { const parent = el.parentNode const pendingNode = parent && parent._pending && parent._pending[vnode.key] if (pendingNode &&