Skip to content

Commit 7a28c8c

Browse files
committed
fix(transition-group): run forceReflow on the correct document (fix #13849)
Previously, `forceReflow()` would always use `document`. When a component with a `TransitionGroup` was moved to another document, move transitions broke because of this. This is fixed by accessing the current instance's `ownerDocument` and using that for the reflow. This is my first time contributing to vue, and I'm not entirely sure if this fix is the right way to go (especially when it comes to perf and possibly unintended side effects).
1 parent 75220c7 commit 7a28c8c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
type FunctionalComponent,
77
assertNumber,
88
compatUtils,
9+
getCurrentInstance,
910
h,
1011
} from '@vue/runtime-core'
1112
import { extend, isArray, isObject, toNumber } from '@vue/shared'
@@ -477,5 +478,6 @@ function toMs(s: string): number {
477478

478479
// synchronously force layout to put elements into a certain state
479480
export function forceReflow(): number {
480-
return document.body.offsetHeight
481+
const instance = getCurrentInstance()!
482+
return instance.vnode.el!.ownerDocument.body.offsetHeight
481483
}

0 commit comments

Comments
 (0)