Skip to content

<Transition> retains detached DOM nodes that already left #11782

@ktsn

Description

@ktsn

Vue version

52cdb0f

Link to minimal reproduction

https://play.vuejs.org/#eNp9UTtPwzAQ/iuHl4JUmgGmKq14qAMMgCCjl5BeglvHtvwIlar8d85OU4qEmsn+XvnuvGf3xsy6gGzOcldZYTw49MEsuRKt0dbDHizW0ENtdQsTkk644qrSynnoShkQFlFx6W3AK67ybIihALp4bI0sPdINIP8M3msFd5UU1XbB2Wi/SAfOloVuGol5NghTBNkKWyonvEgI0JevRQfdtajHDLIODECBzh9UGcmGH2d/IvLspBabMu9omlo0s43Tihaxjx7OKt0aIdG+muhznM0hMZErpdTfzwmLc09HvPrCavsPvnG7iHH2ZtGh7ajxkfOlbdAP9OrjBXd0PpKtXgdJ6jPkOzotQ+w4yB6CWlPtE11q+5SeU6imcKudR1rHYahYNCr7pKeNBnw8M/pv3ZvZbfJx1bP+Bx9owfc=

Steps to reproduce

  1. (On Chrome devtools) Trigger GC and take initial heap snapshot.
  2. Click "Toggle" button twice (Text disappears and appears again)
  3. (On Chrome devtools) Trigger GC again and take second heap snapshot.
  4. Compare 3. and 1.

What is expected?

There is no detached DOM node.

What is actually happening?

There are detached DOM nodes that disappeared on step 2. It is retained by the old vnode in the scope of <Transition> render function via postClone callback of resolveTransitionHooks.

スクリーンショット 2024-09-03 9 50 51

System Info

No response

Any additional comments?

The detached nodes will be released when a next leave transition. So memory usage does not increase forever. But this behavior always keep some detached nodes which makes harder to find actual memory leak. In addition, since it keeps unused DOM tree in memory, it can be a problem under an environment where memory usage is restricted like mobile app's WebView.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions