Răsfoiți Sursa

transition: use more reliable hidden check (close #1398)

Evan You 10 ani în urmă
părinte
comite
a0fa04d513

+ 5 - 3
src/transition/transition.js

@@ -357,9 +357,11 @@ p.setupCssCb = function (event, cb) {
  */
 
 function isHidden (el) {
-  return el.style.display === 'none' ||
-    el.style.visibility === 'hidden' ||
-    el.hidden
+  return !(
+    el.offsetWidth &&
+    el.offsetHeight &&
+    el.getClientRects().length
+  )
 }
 
 module.exports = Transition

+ 3 - 0
test/unit/specs/transition/transition_spec.js

@@ -87,6 +87,7 @@ if (_.inBrowser && !_.isIE9) {
       var el, vm, op, cb
       beforeEach(function () {
         el = document.createElement('div')
+        el.textContent = 'hello'
         op = jasmine.createSpy('transition skip op')
         cb = jasmine.createSpy('transition skip cb')
         vm = new Vue()
@@ -135,6 +136,7 @@ if (_.inBrowser && !_.isIE9) {
       var vm, el, op, cb, hooks
       beforeEach(function (done) {
         el = document.createElement('div')
+        el.textContent = 'hello'
         vm = new Vue({ el: el })
         op = jasmine.createSpy('css op')
         cb = jasmine.createSpy('css cb')
@@ -441,6 +443,7 @@ if (_.inBrowser && !_.isIE9) {
       beforeEach(function () {
         hooks = {}
         el = document.createElement('div')
+        el.textContent = 'hello'
         document.body.appendChild(el)
         op = jasmine.createSpy('js transition op')
         cb = jasmine.createSpy('js transition cb')