File tree 3 files changed +15
-10
lines changed
packages/compiler-vapor/src
3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
10
10
import {
11
11
type BlockFunctionIRNode ,
12
12
DynamicFlag ,
13
- type IRDynamicChildren ,
13
+ type IRDynamicInfo ,
14
14
IRNodeTypes ,
15
15
type OperationNode ,
16
16
type RootIRNode ,
@@ -313,20 +313,23 @@ export function generate(
313
313
}
314
314
}
315
315
316
- function genChildren ( children : IRDynamicChildren ) {
316
+ function genChildren ( children : IRDynamicInfo [ ] ) {
317
317
let code = ''
318
318
let offset = 0
319
- for ( const [ index , child ] of Object . entries ( children ) ) {
320
- const childrenLength = Object . keys ( child . children ) . length
319
+
320
+ for ( const [ index , child ] of children . entries ( ) ) {
321
321
if ( child . dynamicFlags & DynamicFlag . NON_TEMPLATE ) {
322
322
offset --
323
- continue
324
323
}
325
324
326
325
const idx = Number ( index ) + offset
327
326
const id =
328
- child . dynamicFlags & DynamicFlag . INSERT ? child . placeholder : child . id
329
- const childrenString = childrenLength && genChildren ( child . children )
327
+ child . dynamicFlags & DynamicFlag . REFERENCED
328
+ ? child . dynamicFlags & DynamicFlag . INSERT
329
+ ? child . anchor
330
+ : child . id
331
+ : null
332
+ const childrenString = genChildren ( child . children )
330
333
331
334
if ( id !== null || childrenString ) {
332
335
code += ` ${ idx } : [`
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ export enum DynamicFlag {
199
199
export interface IRDynamicInfo {
200
200
id : number | null
201
201
dynamicFlags : DynamicFlag
202
- placeholder : number | null
202
+ anchor : number | null
203
203
children : IRDynamicInfo [ ]
204
204
}
205
205
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ const defaultOptions = {
102
102
export const genDefaultDynamic = ( ) : IRDynamicInfo => ( {
103
103
id : null ,
104
104
dynamicFlags : 0 ,
105
- placeholder : null ,
105
+ anchor : null ,
106
106
children : [ ] ,
107
107
} )
108
108
@@ -335,7 +335,9 @@ function processDynamicChildren(ctx: TransformContext<RootNode | ElementNode>) {
335
335
if ( prevChildren . length ) {
336
336
if ( hasStatic ) {
337
337
ctx . childrenTemplate [ index - prevChildren . length ] = `<!>`
338
- const anchor = ( prevChildren [ 0 ] . placeholder = ctx . increaseId ( ) )
338
+
339
+ prevChildren [ 0 ] . dynamicFlags -= DynamicFlag . NON_TEMPLATE
340
+ const anchor = ( prevChildren [ 0 ] . anchor = ctx . increaseId ( ) )
339
341
340
342
ctx . registerOperation ( {
341
343
type : IRNodeTypes . INSERT_NODE ,
You can’t perform that action at this time.
0 commit comments