diff --git a/src/platforms/web/runtime/components/transition-group.js b/src/platforms/web/runtime/components/transition-group.js index 81d033d5ad5..2ceefed4d5e 100644 --- a/src/platforms/web/runtime/components/transition-group.js +++ b/src/platforms/web/runtime/components/transition-group.js @@ -161,7 +161,7 @@ function callPendingCbs (c: VNode) { c.elm._moveCb() } /* istanbul ignore if */ - if (c.elm._enterCb) { + if (c.elm._enterCb && !Object.keys(c.data.pos).every(key => c.data.pos[key] === 0)) { c.elm._enterCb() } } @@ -175,7 +175,7 @@ function applyTranslation (c: VNode) { const newPos = c.data.newPos const dx = oldPos.left - newPos.left const dy = oldPos.top - newPos.top - if (dx || dy) { + if ((dx || dy) && !Object.keys(oldPos).every(key => oldPos[key] === 0)) { c.data.moved = true const s = c.elm.style s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)` diff --git a/test/unit/features/transition/transition-group.spec.js b/test/unit/features/transition/transition-group.spec.js index 2988d5bff4a..25e80579675 100644 --- a/test/unit/features/transition/transition-group.spec.js +++ b/test/unit/features/transition/transition-group.spec.js @@ -340,5 +340,40 @@ if (!isIE9) { ) }).then(done) }) + + // GitHub issue #7879 + it('should work with v-show like v-if', done => { + const vm = new Vue({ + template: ` +
+ +
foo
+
+
+ `, + data: { ok: false } + }).$mount(el) + + vm.ok = true + waitForUpdate(() => { + expect(vm.$el.innerHTML.replace(/\s?style=""(\s?)/g, '$1')).toBe( + `` + + `
foo
` + + `
` + ) + }).thenWaitFor(nextFrame).then(() => { + expect(vm.$el.innerHTML.replace(/\s?style=""(\s?)/g, '$1')).toBe( + `` + + `
foo
` + + `
` + ) + }).thenWaitFor(duration + buffer).then(() => { + expect(vm.$el.innerHTML.replace(/\s?style=""(\s?)/g, '$1')).toBe( + `` + + `
foo
` + + `
` + ) + }).then(done) + }) }) }