From: daiwei Date: Tue, 20 Jan 2026 07:32:25 +0000 (+0800) Subject: refactor(compiler-vapor): simplify logicalIndex type casting in transformChildren X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0635f54a70d5cf4010be55df99c2af75e2d3a2ec;p=thirdparty%2Fvuejs%2Fcore.git refactor(compiler-vapor): simplify logicalIndex type casting in transformChildren --- diff --git a/packages/compiler-vapor/src/transforms/transformChildren.ts b/packages/compiler-vapor/src/transforms/transformChildren.ts index 1a265c823d..955e03f0c8 100644 --- a/packages/compiler-vapor/src/transforms/transformChildren.ts +++ b/packages/compiler-vapor/src/transforms/transformChildren.ts @@ -63,7 +63,9 @@ function processDynamicChildren(context: TransformContext) { let staticCount = 0 let dynamicCount = 0 let lastInsertionChild: IRDynamicInfo | undefined - const children = context.dynamic.children + const children = context.dynamic.children as (IRDynamicInfo & { + logicalIndex?: number + })[] // Track logical index for each dynamic child // logicalIndex represents the position in SSR DOM (counting fragments as single units) @@ -72,8 +74,7 @@ function processDynamicChildren(context: TransformContext) { for (const [index, child] of children.entries()) { if (child.flags & DynamicFlag.INSERT) { // Assign logical index to this dynamic child - ;(child as IRDynamicInfo & { logicalIndex: number }).logicalIndex = - currentLogicalIndex + child.logicalIndex = currentLogicalIndex prevDynamics.push((lastInsertionChild = child)) currentLogicalIndex++ } @@ -100,7 +101,7 @@ function processDynamicChildren(context: TransformContext) { registerInsertion( prevDynamics, context, - // the logical index of append child (kept for backward compatibility) + // the logical index of append child dynamicCount + staticCount, true, ) @@ -112,14 +113,13 @@ function processDynamicChildren(context: TransformContext) { } function registerInsertion( - dynamics: IRDynamicInfo[], + dynamics: (IRDynamicInfo & { logicalIndex?: number })[], context: TransformContext, anchor: number, append?: boolean, ) { for (const child of dynamics) { - const logicalIndex = (child as IRDynamicInfo & { logicalIndex?: number }) - .logicalIndex + const logicalIndex = child.logicalIndex if (child.template != null) { // template node due to invalid nesting - generate actual insertion context.registerOperation({