소스 검색

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

Evan You 9 년 전
부모
커밋
3627a27179
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  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')