File tree 4 files changed +21
-29
lines changed
packages/compiler-vapor/src
4 files changed +21
-29
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import {
25
25
type VaporDirectiveNode ,
26
26
} from './ir'
27
27
import { isConstantExpression } from './utils'
28
- import { newDynamic } from './transforms/utils'
28
+ import { newBlock , newDynamic } from './transforms/utils'
29
29
30
30
export type NodeTransform = (
31
31
node : RootNode | TemplateChildNode ,
@@ -211,14 +211,7 @@ export function transform(
211
211
source : node . source ,
212
212
template : [ ] ,
213
213
component : new Set ( ) ,
214
- block : {
215
- type : IRNodeTypes . BLOCK ,
216
- node,
217
- dynamic : newDynamic ( ) ,
218
- effect : [ ] ,
219
- operation : [ ] ,
220
- returns : [ ] ,
221
- } ,
214
+ block : newBlock ( node ) ,
222
215
}
223
216
224
217
const context = new TransformContext ( ir , node , options )
Original file line number Diff line number Diff line change @@ -9,13 +9,27 @@ import {
9
9
createSimpleExpression ,
10
10
} from '@vue/compiler-dom'
11
11
import { extend } from '@vue/shared'
12
- import { DynamicFlag , type IRDynamicInfo } from '../ir'
12
+ import {
13
+ type BlockIRNode ,
14
+ DynamicFlag ,
15
+ type IRDynamicInfo ,
16
+ IRNodeTypes ,
17
+ } from '../ir'
13
18
14
19
export const newDynamic = ( ) : IRDynamicInfo => ( {
15
20
flags : DynamicFlag . REFERENCED ,
16
21
children : [ ] ,
17
22
} )
18
23
24
+ export const newBlock = ( node : BlockIRNode [ 'node' ] ) : BlockIRNode => ( {
25
+ type : IRNodeTypes . BLOCK ,
26
+ node,
27
+ dynamic : newDynamic ( ) ,
28
+ effect : [ ] ,
29
+ operation : [ ] ,
30
+ returns : [ ] ,
31
+ } )
32
+
19
33
export function wrapTemplate ( node : ElementNode , dirs : string [ ] ) : TemplateNode {
20
34
if ( node . tagType === ElementTypes . TEMPLATE ) {
21
35
return node
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {
15
15
type VaporDirectiveNode ,
16
16
} from '../ir'
17
17
import { findProp , propToExpression } from '../utils'
18
- import { newDynamic , wrapTemplate } from './utils'
18
+ import { newBlock , wrapTemplate } from './utils'
19
19
20
20
export const transformVFor = createStructuralDirectiveTransform (
21
21
'for' ,
@@ -48,14 +48,7 @@ export function processFor(
48
48
context . node = node = wrapTemplate ( node , [ 'for' ] )
49
49
context . dynamic . flags |= DynamicFlag . NON_TEMPLATE | DynamicFlag . INSERT
50
50
const id = context . reference ( )
51
- const render : BlockIRNode = {
52
- type : IRNodeTypes . BLOCK ,
53
- node,
54
- dynamic : newDynamic ( ) ,
55
- effect : [ ] ,
56
- operation : [ ] ,
57
- returns : [ ] ,
58
- }
51
+ const render : BlockIRNode = newBlock ( node )
59
52
const exitBlock = context . enterBlock ( render , true )
60
53
context . reference ( )
61
54
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {
15
15
type VaporDirectiveNode ,
16
16
} from '../ir'
17
17
import { extend } from '@vue/shared'
18
- import { newDynamic , wrapTemplate } from './utils'
18
+ import { newBlock , wrapTemplate } from './utils'
19
19
import { getSiblingIf } from './transformComment'
20
20
21
21
export const transformVIf = createStructuralDirectiveTransform (
@@ -114,15 +114,7 @@ export function createIfBranch(
114
114
) : [ BlockIRNode , ( ) => void ] {
115
115
context . node = node = wrapTemplate ( node , [ 'if' , 'else-if' , 'else' ] )
116
116
117
- const branch : BlockIRNode = {
118
- type : IRNodeTypes . BLOCK ,
119
- node,
120
- dynamic : newDynamic ( ) ,
121
- effect : [ ] ,
122
- operation : [ ] ,
123
- returns : [ ] ,
124
- }
125
-
117
+ const branch : BlockIRNode = newBlock ( node )
126
118
const exitBlock = context . enterBlock ( branch )
127
119
context . reference ( )
128
120
return [ branch , exitBlock ]
You can’t perform that action at this time.
0 commit comments