feat(directives): introduce created custom directive hook and ensure
`v-model` event listener fire before template/props listeners fix #1931
This commit is contained in:
@@ -41,6 +41,7 @@ export type SSRDirectiveHook = (
|
||||
) => Data | undefined
|
||||
|
||||
export interface ObjectDirective<T = any, V = any> {
|
||||
created?: DirectiveHook<T, null, V>
|
||||
beforeMount?: DirectiveHook<T, null, V>
|
||||
mounted?: DirectiveHook<T, null, V>
|
||||
beforeUpdate?: DirectiveHook<T, VNode<any, T>, V>
|
||||
|
||||
@@ -720,6 +720,9 @@ function baseCreateRenderer(
|
||||
)
|
||||
}
|
||||
|
||||
if (dirs) {
|
||||
invokeDirectiveHook(vnode, null, parentComponent, 'created')
|
||||
}
|
||||
// props
|
||||
if (props) {
|
||||
for (const key in props) {
|
||||
@@ -741,10 +744,6 @@ function baseCreateRenderer(
|
||||
invokeVNodeHook(vnodeHook, parentComponent, vnode)
|
||||
}
|
||||
}
|
||||
if (dirs) {
|
||||
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
|
||||
}
|
||||
|
||||
// scopeId
|
||||
if (scopeId) {
|
||||
hostSetScopeId(el, scopeId)
|
||||
@@ -756,6 +755,9 @@ function baseCreateRenderer(
|
||||
hostSetScopeId(el, treeOwnerId + '-s')
|
||||
}
|
||||
}
|
||||
if (dirs) {
|
||||
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
|
||||
}
|
||||
// #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
|
||||
// #1689 For inside suspense + suspense resolved case, just call it
|
||||
const needCallTransitionHooks =
|
||||
|
||||
Reference in New Issue
Block a user