@@ -12,13 +12,13 @@ export default {
12
12
}
13
13
}
14
14
15
- function updateDirectives (
16
- oldVnode : VNodeWithData ,
17
- vnode : VNodeWithData
18
- ) {
19
- if ( ! oldVnode . data . directives && ! vnode . data . directives ) {
20
- return
15
+ function updateDirectives ( oldVnode : VNodeWithData , vnode : VNodeWithData ) {
16
+ if ( oldVnode . data . directives || vnode . data . directives ) {
17
+ _update ( oldVnode , vnode )
21
18
}
19
+ }
20
+
21
+ function _update ( oldVnode , vnode ) {
22
22
const isCreate = oldVnode === emptyNode
23
23
const oldDirs = normalizeDirectives ( oldVnode . data . directives , oldVnode . context )
24
24
const newDirs = normalizeDirectives ( vnode . data . directives , vnode . context )
@@ -48,9 +48,9 @@ function updateDirectives (
48
48
49
49
if ( dirsWithInsert . length ) {
50
50
const callInsert = ( ) => {
51
- dirsWithInsert . forEach ( dir => {
52
- callHook ( dir , 'inserted' , vnode , oldVnode )
53
- } )
51
+ for ( let i = 0 ; i < dirsWithInsert . length ; i ++ ) {
52
+ callHook ( dirsWithInsert [ i ] , 'inserted' , vnode , oldVnode )
53
+ }
54
54
}
55
55
if ( isCreate ) {
56
56
mergeVNodeHook ( vnode . data . hook || ( vnode . data . hook = { } ) , 'insert' , callInsert , 'dir-insert' )
@@ -61,9 +61,9 @@ function updateDirectives (
61
61
62
62
if ( dirsWithPostpatch . length ) {
63
63
mergeVNodeHook ( vnode . data . hook || ( vnode . data . hook = { } ) , 'postpatch' , ( ) => {
64
- dirsWithPostpatch . forEach ( dir => {
65
- callHook ( dir , 'componentUpdated' , vnode , oldVnode )
66
- } )
64
+ for ( let i = 0 ; i < dirsWithPostpatch . length ; i ++ ) {
65
+ callHook ( dirsWithPostpatch [ i ] , 'componentUpdated' , vnode , oldVnode )
66
+ }
67
67
} , 'dir-postpatch' )
68
68
}
69
69
0 commit comments