MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / commitContainer

Function commitContainer

packages/core/src/runtime/commit/container.ts:87–409  ·  view source on GitHub ↗
(
  instanceId: InstanceId,
  vnode: VNode,
  prev: RuntimeInstance | null,
  ctx: CommitCtx,
  nodePath: string[],
  depth: number,
  commitNode: CommitNodeFn,
)

Source from the content-addressed store, hash-verified

85}
86
87export function commitContainer(
88 instanceId: InstanceId,
89 vnode: VNode,
90 prev: RuntimeInstance | null,
91 ctx: CommitCtx,
92 nodePath: string[],
93 depth: number,
94 commitNode: CommitNodeFn,
95): CommitNodeResult {
96 void depth;
97 const parentProps = vnode.props as { id?: unknown } | undefined;
98 const parentId =
99 typeof parentProps?.id === "string" && parentProps.id.length > 0 ? parentProps.id : undefined;
100
101 const prevChildren = prev ? prev.children : [];
102 const compositeWrapperChildren = ctx.containerChildOverrides.get(instanceId) ?? null;
103 const res = reconcileChildren(
104 instanceId,
105 prevChildren,
106 compositeWrapperChildren ? compositeWrapperChildren : commitChildrenForVNode(vnode),
107 ctx.allocator,
108 {
109 kind: vnode.kind,
110 ...(parentId === undefined ? {} : { id: parentId }),
111 },
112 );
113 if (!res.ok) return { ok: false, fatal: res.fatal };
114
115 const byPrevIndex = prevChildren;
116 let byPrevInstanceId: Map<InstanceId, RuntimeInstance> | null = null;
117 if (res.value.unmountedInstanceIds.length > 0) {
118 byPrevInstanceId = new Map<InstanceId, RuntimeInstance>();
119 for (const c of prevChildren) byPrevInstanceId.set(c.instanceId, c);
120 }
121
122 const parentCompositeTheme = currentCompositeTheme(ctx);
123 let pushedCompositeTheme = false;
124 if (parentCompositeTheme !== null) {
125 const nextCompositeTheme = resolveCompositeChildTheme(parentCompositeTheme, vnode);
126 if (nextCompositeTheme !== parentCompositeTheme) {
127 ctx.compositeThemeStack.push(nextCompositeTheme);
128 pushedCompositeTheme = true;
129 }
130 }
131
132 try {
133 const canTryFastReuse =
134 prev !== null &&
135 res.value.newInstanceIds.length === 0 &&
136 res.value.unmountedInstanceIds.length === 0 &&
137 res.value.nextChildren.length === prevChildren.length;
138 let childOrderStable = true;
139 if (canTryFastReuse) {
140 for (let i = 0; i < res.value.nextChildren.length; i++) {
141 const child = res.value.nextChildren[i];
142 if (!child || child.prevIndex !== i) {
143 childOrderStable = false;
144 break;

Callers 2

commitNodeFunction · 0.85
executeCompositeRenderFunction · 0.85

Calls 15

reconcileChildrenFunction · 0.85
commitChildrenForVNodeFunction · 0.85
currentCompositeThemeFunction · 0.85
commitNodeFunction · 0.85
formatNodePathFunction · 0.85
appendNodePathFunction · 0.85
rewriteCommittedVNodeFunction · 0.85
hasDirtyChildFunction · 0.85
diagWhichPropFailsFunction · 0.85
tryScheduleExitAnimationFunction · 0.85

Tested by

no test coverage detected