Skip to content

Commit 1be5ddf

Browse files
authored
fix(transition-group): run forceReflow on the correct document (fix #13849) (#13853)
close #13849
1 parent d44a5a9 commit 1be5ddf

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/runtime-dom/src/components/Transition.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ export function resolveTransitionProps(
260260
// the css will not get the final state (#10677)
261261
if (!el._enterCancelled) {
262262
// force reflow so *-leave-from classes immediately take effect (#2593)
263-
forceReflow()
263+
forceReflow(el)
264264
addTransitionClass(el, leaveActiveClass)
265265
} else {
266266
addTransitionClass(el, leaveActiveClass)
267-
forceReflow()
267+
forceReflow(el)
268268
}
269269
nextFrame(() => {
270270
if (!el._isLeaving) {
@@ -476,6 +476,7 @@ function toMs(s: string): number {
476476
}
477477

478478
// synchronously force layout to put elements into a certain state
479-
export function forceReflow(): number {
480-
return document.body.offsetHeight
479+
export function forceReflow(el?: Node): number {
480+
const targetDocument = el ? el.ownerDocument! : document
481+
return targetDocument.body.offsetHeight
481482
}

packages/runtime-dom/src/components/TransitionGroup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const TransitionGroupImpl: ComponentOptions = /*@__PURE__*/ decorate({
9292
const movedChildren = prevChildren.filter(applyTranslation)
9393

9494
// force reflow to put everything in position
95-
forceReflow()
95+
forceReflow(instance.vnode.el as Node)
9696

9797
movedChildren.forEach(c => {
9898
const el = c.el as ElementWithTransition

0 commit comments

Comments
 (0)