fix: defer reactive props in branch pre-rendering
This commit is contained in:
@@ -1739,6 +1739,15 @@ export function createHandlers(deps: RuntimeDeps): Handlers {
|
||||
// Props may carry `{t:key}` i18n markers — resolve them for the active
|
||||
// language before handing them to the component.
|
||||
const props = resolveTProps(parseComponentProps(attrStr!), translate);
|
||||
// Client control templates retain reactive expressions (for example
|
||||
// `metrics="{metrics}"`) because their parent state is not available
|
||||
// while we pre-render the inert branch metadata. Do not feed those
|
||||
// expression strings into typed component coercion. Rendering with the
|
||||
// component defaults creates the real child boundary; the bridged prop
|
||||
// binding synchronizes the live value when the branch is instantiated.
|
||||
for (const [key, value] of Object.entries(props)) {
|
||||
if (/^\{[\s\S]*\}$/.test(value) && !/^\{t:/.test(value)) delete props[key];
|
||||
}
|
||||
if (normalizedName === "languageswitcher" && deps.i18n) {
|
||||
props.locales ??= JSON.stringify(
|
||||
deps.i18n.langs.map((locale) => ({
|
||||
@@ -2682,7 +2691,12 @@ export function parseComponentProps(attrStr: string): Record<string, string> {
|
||||
const props: Record<string, string> = {};
|
||||
for (const m of attrStr.matchAll(/([A-Za-z_][\w-]*)(?:="([^"]*)")?/g)) {
|
||||
const key = m[1]!;
|
||||
if (key === "data-component") continue;
|
||||
if (
|
||||
key === "data-component" ||
|
||||
key.startsWith("data-wrn-bind-") ||
|
||||
key.startsWith("data-wrn-prop-bind-")
|
||||
)
|
||||
continue;
|
||||
props[key] = decodeHtmlEntities(m[2] ?? "");
|
||||
}
|
||||
return props;
|
||||
|
||||
Reference in New Issue
Block a user