From b4e84fd8715cdc2c567438c4f7ded5c948617528 Mon Sep 17 00:00:00 2001 From: zhizheng Date: Sun, 27 Apr 2025 18:27:50 +0000 Subject: [PATCH] Fix: Prevent input value leakage by generating unique keys for PartialComp([2.0 bug] different/incorrect behaviour due to bump fresh@1.7.3 up to @fresh/core@^2.0.0-alpha.29 #2850) --- src/runtime/client/partials.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/runtime/client/partials.ts b/src/runtime/client/partials.ts index 41a2c1e92ed..e606a674f95 100644 --- a/src/runtime/client/partials.ts +++ b/src/runtime/client/partials.ts @@ -457,8 +457,11 @@ function revivePartials( sib as Comment, ); + // Always generate a unique key for PartialComp to avoid vnode reuse when switching partials, which fixes input value leakage issues. + const uniqueKey = (partialKey !== "" ? partialKey : "partial") + "-" + + Date.now(); const root = h(PartialComp, { - key: partialKey !== "" ? partialKey : undefined, + key: uniqueKey, name: partialName, mode: partialMode, children: null,