Bläddra i källkod

ensure custom directive bind is called after node is inserted (close #3529)

Evan You 9 år sedan
förälder
incheckning
3627a27179
1 ändrade filer med 4 tillägg och 1 borttagningar
  1. 4 1
      src/core/vdom/modules/directives.js

+ 4 - 1
src/core/vdom/modules/directives.js

@@ -1,10 +1,13 @@
 /* @flow */
 
 import { resolveAsset } from 'core/util/options'
+import { mergeVNodeHook } from 'core/vdom/helpers'
 
 export default {
   create: function bindDirectives (oldVnode: VNodeWithData, vnode: VNodeWithData) {
-    applyDirectives(oldVnode, vnode, 'bind')
+    mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', () => {
+      applyDirectives(oldVnode, vnode, 'bind')
+    })
   },
   update: function updateDirectives (oldVnode: VNodeWithData, vnode: VNodeWithData) {
     applyDirectives(oldVnode, vnode, 'update')