Skip to content

Commit d535c64

Browse files
committed
refactor(compiler-vapor): new dynamic info
1 parent 784310d commit d535c64

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

packages/compiler-vapor/src/transform.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
type VaporDirectiveNode,
2626
} from './ir'
2727
import { isConstantExpression } from './utils'
28-
import { genDefaultDynamic } from './transforms/utils'
28+
import { newDynamic } from './transforms/utils'
2929

3030
export type NodeTransform = (
3131
node: RootNode | TemplateChildNode,
@@ -174,7 +174,7 @@ export class TransformContext<T extends AllNode = AllNode> {
174174

175175
template: '',
176176
childrenTemplate: [],
177-
dynamic: genDefaultDynamic(),
177+
dynamic: newDynamic(),
178178
} satisfies Partial<TransformContext<T>>)
179179
}
180180
}
@@ -217,9 +217,7 @@ export function transform(
217217
block: {
218218
type: IRNodeTypes.BLOCK,
219219
node: root,
220-
dynamic: extend(genDefaultDynamic(), {
221-
flags: DynamicFlag.REFERENCED,
222-
} satisfies Partial<IRDynamicInfo>),
220+
dynamic: newDynamic(),
223221
effect: [],
224222
operation: [],
225223
returns: [],

packages/compiler-vapor/src/transforms/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {
1111
import { extend } from '@vue/shared'
1212
import { DynamicFlag, type IRDynamicInfo } from '../ir'
1313

14-
export const genDefaultDynamic = (): IRDynamicInfo => ({
15-
flags: DynamicFlag.NONE,
14+
export const newDynamic = (): IRDynamicInfo => ({
15+
flags: DynamicFlag.REFERENCED,
1616
children: [],
1717
})
1818

packages/compiler-vapor/src/transforms/vFor.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ import {
1111
import {
1212
type BlockIRNode,
1313
DynamicFlag,
14-
type IRDynamicInfo,
1514
IRNodeTypes,
1615
type VaporDirectiveNode,
1716
} from '../ir'
18-
import { extend } from '@vue/shared'
1917
import { findProp, propToExpression } from '../utils'
20-
import { genDefaultDynamic, wrapTemplate } from './utils'
18+
import { newDynamic, wrapTemplate } from './utils'
2119

2220
export const transformVFor = createStructuralDirectiveTransform(
2321
'for',
@@ -53,9 +51,7 @@ export function processFor(
5351
const render: BlockIRNode = {
5452
type: IRNodeTypes.BLOCK,
5553
node,
56-
dynamic: extend(genDefaultDynamic(), {
57-
flags: DynamicFlag.REFERENCED,
58-
} satisfies Partial<IRDynamicInfo>),
54+
dynamic: newDynamic(),
5955
effect: [],
6056
operation: [],
6157
returns: [],

packages/compiler-vapor/src/transforms/vIf.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ import {
1111
import {
1212
type BlockIRNode,
1313
DynamicFlag,
14-
type IRDynamicInfo,
1514
IRNodeTypes,
1615
type VaporDirectiveNode,
1716
} from '../ir'
1817
import { extend } from '@vue/shared'
19-
import { genDefaultDynamic, wrapTemplate } from './utils'
18+
import { newDynamic, wrapTemplate } from './utils'
2019
import { getSiblingIf } from './transformComment'
2120

2221
export const transformVIf = createStructuralDirectiveTransform(
@@ -118,9 +117,7 @@ export function createIfBranch(
118117
const branch: BlockIRNode = {
119118
type: IRNodeTypes.BLOCK,
120119
node,
121-
dynamic: extend(genDefaultDynamic(), {
122-
flags: DynamicFlag.REFERENCED,
123-
} satisfies Partial<IRDynamicInfo>),
120+
dynamic: newDynamic(),
124121
effect: [],
125122
operation: [],
126123
returns: [],

0 commit comments

Comments
 (0)