فهرست منبع

do not attempt to apply v-show leave transition if element is out-of-DOM (fix #2022)

Evan You 10 سال پیش
والد
کامیت
d6ee905f20
1فایلهای تغییر یافته به همراه8 افزوده شده و 3 حذف شده
  1. 8 3
      src/directives/public/show.js

+ 8 - 3
src/directives/public/show.js

@@ -1,4 +1,4 @@
-import { getAttr } from '../../util/index'
+import { getAttr, inDoc } from '../../util/index'
 import { applyTransition } from '../../transition/index'
 
 export default {
@@ -19,8 +19,13 @@ export default {
   },
 
   apply (el, value) {
-    applyTransition(el, value ? 1 : -1, function () {
+    if (inDoc(el)) {
+      applyTransition(el, value ? 1 : -1, toggle, this.vm)
+    } else {
+      toggle()
+    }
+    function toggle () {
       el.style.display = value ? '' : 'none'
-    }, this.vm)
+    }
   }
 }