]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(compiler-vapor): simplify logicalIndex type casting in transformChildren
authordaiwei <daiwei521@126.com>
Tue, 20 Jan 2026 07:32:25 +0000 (15:32 +0800)
committerdaiwei <daiwei521@126.com>
Tue, 20 Jan 2026 07:32:25 +0000 (15:32 +0800)
packages/compiler-vapor/src/transforms/transformChildren.ts

index 1a265c823db043837ff091e675f664ec639ba28f..955e03f0c89380a381389e20c7a4b7d2d97d7cde 100644 (file)
@@ -63,7 +63,9 @@ function processDynamicChildren(context: TransformContext<ElementNode>) {
   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<ElementNode>) {
   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<ElementNode>) {
     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<ElementNode>) {
 }
 
 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({