feat: Nested partials support (#1955)

This commit is contained in:
Tiago Gimenes
2023-10-18 18:26:46 +02:00
committed by GitHub
parent b984da9113
commit 84ff79beca
6 changed files with 162 additions and 33 deletions
+5 -11
View File
@@ -103,17 +103,12 @@ export function revive(
);
for (let i = 0; i < result.length; i++) {
const { vnode, marker, rootFragment } = result[i];
const { vnode, rootFragment } = result[i];
const _render = () => {
render(
vnode,
rootFragment,
);
if (marker.kind === MarkerKind.Partial) {
// deno-lint-ignore no-explicit-any
partials.set(marker.text, (vnode as any).__c);
}
};
"scheduler" in window
@@ -149,6 +144,10 @@ function addPropsChild(parent: VNode, vnode: ComponentChildren) {
class PartialComp extends Component<
{ children?: ComponentChildren; mode: number; name: string }
> {
componentDidMount() {
partials.set(this.props.name, this);
}
render() {
return this.props.children;
}
@@ -432,11 +431,6 @@ function _walkInner(
const parent = vnodeStack[vnodeStack.length - 1]!;
addPropsChild(parent, vnode);
if (marker.kind === MarkerKind.Partial) {
// deno-lint-ignore no-explicit-any
partials.set(marker.text, (vnode as any).__c);
}
sib = marker.endNode.nextSibling;
continue;
}