This repository was archived by the owner on Jul 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +21
-29
lines changed
packages/compiler-vapor/src Expand file tree Collapse file tree 4 files changed +21
-29
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import {
2525 type VaporDirectiveNode ,
2626} from './ir'
2727import { isConstantExpression } from './utils'
28- import { newDynamic } from './transforms/utils'
28+ import { newBlock , newDynamic } from './transforms/utils'
2929
3030export type NodeTransform = (
3131 node : RootNode | TemplateChildNode ,
@@ -211,14 +211,7 @@ export function transform(
211211 source : node . source ,
212212 template : [ ] ,
213213 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 ) ,
222215 }
223216
224217 const context = new TransformContext ( ir , node , options )
Original file line number Diff line number Diff line change @@ -9,13 +9,27 @@ import {
99 createSimpleExpression ,
1010} from '@vue/compiler-dom'
1111import { 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'
1318
1419export const newDynamic = ( ) : IRDynamicInfo => ( {
1520 flags : DynamicFlag . REFERENCED ,
1621 children : [ ] ,
1722} )
1823
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+
1933export function wrapTemplate ( node : ElementNode , dirs : string [ ] ) : TemplateNode {
2034 if ( node . tagType === ElementTypes . TEMPLATE ) {
2135 return node
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {
1515 type VaporDirectiveNode ,
1616} from '../ir'
1717import { findProp , propToExpression } from '../utils'
18- import { newDynamic , wrapTemplate } from './utils'
18+ import { newBlock , wrapTemplate } from './utils'
1919
2020export const transformVFor = createStructuralDirectiveTransform (
2121 'for' ,
@@ -48,14 +48,7 @@ export function processFor(
4848 context . node = node = wrapTemplate ( node , [ 'for' ] )
4949 context . dynamic . flags |= DynamicFlag . NON_TEMPLATE | DynamicFlag . INSERT
5050 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 )
5952 const exitBlock = context . enterBlock ( render , true )
6053 context . reference ( )
6154
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {
1515 type VaporDirectiveNode ,
1616} from '../ir'
1717import { extend } from '@vue/shared'
18- import { newDynamic , wrapTemplate } from './utils'
18+ import { newBlock , wrapTemplate } from './utils'
1919import { getSiblingIf } from './transformComment'
2020
2121export const transformVIf = createStructuralDirectiveTransform (
@@ -114,15 +114,7 @@ export function createIfBranch(
114114) : [ BlockIRNode , ( ) => void ] {
115115 context . node = node = wrapTemplate ( node , [ 'if' , 'else-if' , 'else' ] )
116116
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 )
126118 const exitBlock = context . enterBlock ( branch )
127119 context . reference ( )
128120 return [ branch , exitBlock ]
You can’t perform that action at this time.
0 commit comments