@@ -560,15 +560,18 @@ describe('compiler: v-for', () => {
560
560
function assertSharedCodegen (
561
561
node : ForCodegenNode ,
562
562
keyed : boolean = false ,
563
- customReturn : boolean = false
563
+ customReturn : boolean = false ,
564
+ disableTracking : boolean = true
564
565
) {
565
566
expect ( node ) . toMatchObject ( {
566
567
type : NodeTypes . VNODE_CALL ,
567
568
tag : FRAGMENT ,
568
- isForBlock : true ,
569
- patchFlag : keyed
570
- ? genFlagText ( PatchFlags . KEYED_FRAGMENT )
571
- : genFlagText ( PatchFlags . UNKEYED_FRAGMENT ) ,
569
+ disableTracking,
570
+ patchFlag : ! disableTracking
571
+ ? genFlagText ( PatchFlags . STABLE_FRAGMENT )
572
+ : keyed
573
+ ? genFlagText ( PatchFlags . KEYED_FRAGMENT )
574
+ : genFlagText ( PatchFlags . UNKEYED_FRAGMENT ) ,
572
575
children : {
573
576
type : NodeTypes . JS_CALL_EXPRESSION ,
574
577
callee : RENDER_LIST ,
@@ -580,7 +583,7 @@ describe('compiler: v-for', () => {
580
583
? { }
581
584
: {
582
585
type : NodeTypes . VNODE_CALL ,
583
- isBlock : true
586
+ isBlock : disableTracking
584
587
}
585
588
}
586
589
]
@@ -658,6 +661,43 @@ describe('compiler: v-for', () => {
658
661
expect ( generate ( root ) . code ) . toMatchSnapshot ( )
659
662
} )
660
663
664
+ test ( 'v-for with constant expression' , ( ) => {
665
+ const {
666
+ root,
667
+ node : { codegenNode }
668
+ } = parseWithForTransform ( '<p v-for="item in 10">{{item}}</p>' , {
669
+ prefixIdentifiers : true
670
+ } )
671
+
672
+ expect (
673
+ assertSharedCodegen (
674
+ codegenNode ,
675
+ false /* keyed */ ,
676
+ false /* customReturn */ ,
677
+ false /* disableTracking */
678
+ )
679
+ ) . toMatchObject ( {
680
+ source : { content : `10` , isConstant : true } ,
681
+ params : [ { content : `item` } ] ,
682
+ innerVNodeCall : {
683
+ tag : `"p"` ,
684
+ props : undefined ,
685
+ isBlock : false ,
686
+ children : {
687
+ type : NodeTypes . INTERPOLATION ,
688
+ content : {
689
+ type : NodeTypes . SIMPLE_EXPRESSION ,
690
+ content : 'item' ,
691
+ isStatic : false ,
692
+ isConstant : false
693
+ }
694
+ } ,
695
+ patchFlag : genFlagText ( PatchFlags . TEXT )
696
+ }
697
+ } )
698
+ expect ( generate ( root ) . code ) . toMatchSnapshot ( )
699
+ } )
700
+
661
701
test ( 'template v-for' , ( ) => {
662
702
const {
663
703
root,
@@ -777,7 +817,7 @@ describe('compiler: v-for', () => {
777
817
key : `[0]`
778
818
} ) ,
779
819
isBlock : true ,
780
- isForBlock : true ,
820
+ disableTracking : true ,
781
821
patchFlag : genFlagText ( PatchFlags . UNKEYED_FRAGMENT ) ,
782
822
children : {
783
823
type : NodeTypes . JS_CALL_EXPRESSION ,
0 commit comments