1
- import type {
1
+ import {
2
+ type RootNode ,
3
+ type Node ,
4
+ type TemplateChildNode ,
5
+ type ElementNode ,
6
+ type AttributeNode ,
7
+ type InterpolationNode ,
8
+ type TransformOptions ,
9
+ type DirectiveNode ,
10
+ type ExpressionNode ,
2
11
NodeTypes ,
3
- RootNode ,
4
- Node ,
5
- TemplateChildNode ,
6
- ElementNode ,
7
- AttributeNode ,
8
- InterpolationNode ,
9
- TransformOptions ,
10
- DirectiveNode ,
11
- ExpressionNode ,
12
12
} from '@vue/compiler-dom'
13
13
import {
14
14
type OperationNode ,
@@ -235,27 +235,27 @@ function transformChildren(
235
235
const isLast = index === children . length - 1
236
236
237
237
switch ( node . type ) {
238
- case 1 satisfies NodeTypes . ELEMENT : {
238
+ case NodeTypes . ELEMENT : {
239
239
transformElement ( child as TransformContext < ElementNode > )
240
240
break
241
241
}
242
- case 2 satisfies NodeTypes . TEXT : {
242
+ case NodeTypes . TEXT : {
243
243
child . template += node . content
244
244
break
245
245
}
246
- case 3 satisfies NodeTypes . COMMENT : {
246
+ case NodeTypes . COMMENT : {
247
247
child . template += `<!--${ node . content } -->`
248
248
break
249
249
}
250
- case 5 satisfies NodeTypes . INTERPOLATION : {
250
+ case NodeTypes . INTERPOLATION : {
251
251
transformInterpolation (
252
252
child as TransformContext < InterpolationNode > ,
253
253
isFirst ,
254
254
isLast ,
255
255
)
256
256
break
257
257
}
258
- case 12 satisfies NodeTypes . TEXT_CALL :
258
+ case NodeTypes . TEXT_CALL :
259
259
// never?
260
260
break
261
261
default : {
@@ -305,7 +305,7 @@ function transformInterpolation(
305
305
) {
306
306
const { node } = ctx
307
307
308
- if ( node . content . type === ( 8 satisfies NodeTypes . COMPOUND_EXPRESSION ) ) {
308
+ if ( node . content . type === NodeTypes . COMPOUND_EXPRESSION ) {
309
309
// TODO: CompoundExpressionNode: {{ count + 1 }}
310
310
return
311
311
}
@@ -345,7 +345,7 @@ function transformProp(
345
345
) : void {
346
346
const { name } = node
347
347
348
- if ( node . type === ( 6 satisfies NodeTypes . ATTRIBUTE ) ) {
348
+ if ( node . type === NodeTypes . ATTRIBUTE ) {
349
349
if ( node . value ) {
350
350
ctx . template += ` ${ name } ="${ node . value . content } "`
351
351
} else {
@@ -361,8 +361,7 @@ function transformProp(
361
361
case 'bind' : {
362
362
if (
363
363
! exp ||
364
- ( exp . type === ( 4 satisfies NodeTypes . SIMPLE_EXPRESSION ) &&
365
- ! exp . content . trim ( ) )
364
+ ( exp . type === NodeTypes . SIMPLE_EXPRESSION && ! exp . content . trim ( ) )
366
365
) {
367
366
ctx . options . onError ! (
368
367
createCompilerError ( ErrorCodes . VAPOR_BIND_NO_EXPRESSION , loc ) ,
@@ -377,9 +376,7 @@ function transformProp(
377
376
} else if ( ! node . arg ) {
378
377
// TODO support v-bind="{}"
379
378
return
380
- } else if (
381
- node . arg . type === ( 8 satisfies NodeTypes . COMPOUND_EXPRESSION )
382
- ) {
379
+ } else if ( node . arg . type === NodeTypes . COMPOUND_EXPRESSION ) {
383
380
// TODO support :[foo]="bar"
384
381
return
385
382
}
@@ -404,9 +401,7 @@ function transformProp(
404
401
if ( ! node . arg ) {
405
402
// TODO support v-on="{}"
406
403
return
407
- } else if (
408
- node . arg . type === ( 8 satisfies NodeTypes . COMPOUND_EXPRESSION )
409
- ) {
404
+ } else if ( node . arg . type === NodeTypes . COMPOUND_EXPRESSION ) {
410
405
// TODO support @[foo]="bar"
411
406
return
412
407
} else if ( expr === null ) {
@@ -461,7 +456,7 @@ function processExpression(
461
456
expr : ExpressionNode | undefined ,
462
457
) : string | null {
463
458
if ( ! expr ) return null
464
- if ( expr . type === ( 8 satisfies NodeTypes . COMPOUND_EXPRESSION ) ) {
459
+ if ( expr . type === NodeTypes . COMPOUND_EXPRESSION ) {
465
460
// TODO
466
461
return ''
467
462
}
0 commit comments