소스 검색

ensure instance-unique keys for <transition> child nodes during pending node removal (fix #4702)

Evan You 9 년 전
부모
커밋
85d6f115bb
2개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 3
      src/platforms/web/runtime/components/transition.js
  2. 0 1
      src/platforms/web/runtime/modules/transition.js

+ 7 - 3
src/platforms/web/runtime/components/transition.js

@@ -127,9 +127,13 @@ export default {
       return placeholder(h, rawChild)
     }
 
-    const key = child.key = child.key == null || child.isStatic
-      ? `__v${child.tag + this._uid}__`
-      : child.key
+    // ensure a key that is unique to the vnode type and to this transition
+    // component instance. This key will be used to remove pending leaving nodes
+    // during entering.
+    const id = `__transition-${this._uid}-`
+    const key = child.key = child.key == null
+      ? id + child.tag
+      : child.key.indexOf(id) === 0 ? child.key : id + child.key
     const data = (child.data || (child.data = {})).transition = extractTransitionData(this)
     const oldRawChild = this._vnode
     const oldChild: any = getRealChild(oldRawChild)

+ 0 - 1
src/platforms/web/runtime/modules/transition.js

@@ -103,7 +103,6 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
       const parent = el.parentNode
       const pendingNode = parent && parent._pending && parent._pending[vnode.key]
       if (pendingNode &&
-          pendingNode.context === vnode.context &&
           pendingNode.tag === vnode.tag &&
           pendingNode.elm._leaveCb) {
         pendingNode.elm._leaveCb()