Skip to content

Commit 54586ca

Browse files
pengchongfupengchongfu
authored and
pengchongfu
committed
fix(transition-group): not add class v-move to v-show element, fix #7879
1 parent 6226503 commit 54586ca

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/platforms/web/runtime/components/transition-group.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function callPendingCbs (c: VNode) {
161161
c.elm._moveCb()
162162
}
163163
/* istanbul ignore if */
164-
if (c.elm._enterCb) {
164+
if (c.elm._enterCb && !Object.keys(c.data.pos).every(key => c.data.pos[key] === 0)) {
165165
c.elm._enterCb()
166166
}
167167
}
@@ -175,7 +175,7 @@ function applyTranslation (c: VNode) {
175175
const newPos = c.data.newPos
176176
const dx = oldPos.left - newPos.left
177177
const dy = oldPos.top - newPos.top
178-
if (dx || dy) {
178+
if ((dx || dy) && !Object.keys(oldPos).every(key => oldPos[key] === 0)) {
179179
c.data.moved = true
180180
const s = c.elm.style
181181
s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`

test/unit/features/transition/transition-group.spec.js

+35
Original file line numberDiff line numberDiff line change
@@ -340,5 +340,40 @@ if (!isIE9) {
340340
)
341341
}).then(done)
342342
})
343+
344+
// GitHub issue #7879
345+
it('should work with v-show like v-if', done => {
346+
const vm = new Vue({
347+
template: `
348+
<div>
349+
<transition-group name="group">
350+
<div v-show="ok" key="foo" class="test">foo</div>
351+
</transition-group>
352+
</div>
353+
`,
354+
data: { ok: false }
355+
}).$mount(el)
356+
357+
vm.ok = true
358+
waitForUpdate(() => {
359+
expect(vm.$el.innerHTML.replace(/\s?style=""(\s?)/g, '$1')).toBe(
360+
`<span>` +
361+
`<div class="test group-enter group-enter-active">foo</div>` +
362+
`</span>`
363+
)
364+
}).thenWaitFor(nextFrame).then(() => {
365+
expect(vm.$el.innerHTML.replace(/\s?style=""(\s?)/g, '$1')).toBe(
366+
`<span>` +
367+
`<div class="test group-enter-active group-enter-to">foo</div>` +
368+
`</span>`
369+
)
370+
}).thenWaitFor(duration + buffer).then(() => {
371+
expect(vm.$el.innerHTML.replace(/\s?style=""(\s?)/g, '$1')).toBe(
372+
`<span>` +
373+
`<div class="test">foo</div>` +
374+
`</span>`
375+
)
376+
}).then(done)
377+
})
343378
})
344379
}

0 commit comments

Comments
 (0)