fix: error on duplicate partial name (#1958)

This commit is contained in:
Marvin Hagemeister
2023-10-18 20:04:37 +02:00
committed by GitHub
parent 4c59f9df65
commit 7896005329
5 changed files with 199 additions and 141 deletions
+8 -1
View File
@@ -367,6 +367,13 @@ options.__b = (vnode: VNode<Record<string, unknown>>) => {
`<Partial> components cannot be used inside islands.`,
);
}
const name = vnode.props.name as string;
if (current.encounteredPartials.has(name)) {
current.error = new Error(
`Duplicate partial name "${name}" found. The partial name prop is expected to be unique among partial components.`,
);
}
current.encounteredPartials.add(name);
const mode = encodePartialMode(
// deno-lint-ignore no-explicit-any
@@ -374,7 +381,7 @@ options.__b = (vnode: VNode<Record<string, unknown>>) => {
);
vnode.props.children = wrapWithMarker(
vnode.props.children,
`frsh-partial:${vnode.props.name}:${mode}:${vnode.key ?? ""}`,
`frsh-partial:${name}:${mode}:${vnode.key ?? ""}`,
);
} else if (
vnode.key && (current.islandDepth > 0 || current.partialDepth > 0)