@@ -37,7 +37,7 @@ import { transformStyle } from '../../../compiler-dom/src/transforms/transformSt
37
37
import { transformOn } from '../../src/transforms/vOn'
38
38
import { transformBind } from '../../src/transforms/vBind'
39
39
import { PatchFlags } from '@vue/shared'
40
- import { createObjectMatcher , genFlagText } from '../testUtils'
40
+ import { createObjectMatcher } from '../testUtils'
41
41
import { transformText } from '../../src/transforms/transformText'
42
42
import { parseWithForTransform } from './vFor.spec'
43
43
@@ -521,7 +521,7 @@ describe('compiler: element transform', () => {
521
521
// keep-alive should not compile content to slots
522
522
children : [ { type : NodeTypes . ELEMENT , tag : 'span' } ] ,
523
523
// should get a dynamic slots flag to force updates
524
- patchFlag : genFlagText ( PatchFlags . DYNAMIC_SLOTS ) ,
524
+ patchFlag : PatchFlags . DYNAMIC_SLOTS ,
525
525
} )
526
526
}
527
527
@@ -588,7 +588,7 @@ describe('compiler: element transform', () => {
588
588
} )
589
589
// should factor in props returned by custom directive transforms
590
590
// in patchFlag analysis
591
- expect ( node . patchFlag ) . toMatch ( PatchFlags . PROPS + '' )
591
+ expect ( node . patchFlag ) . toBe ( PatchFlags . PROPS )
592
592
expect ( node . dynamicProps ) . toMatch ( `"bar"` )
593
593
} )
594
594
@@ -612,7 +612,7 @@ describe('compiler: element transform', () => {
612
612
tag : `"div"` ,
613
613
props : undefined ,
614
614
children : undefined ,
615
- patchFlag : genFlagText ( PatchFlags . NEED_PATCH ) , // should generate appropriate flag
615
+ patchFlag : PatchFlags . NEED_PATCH , // should generate appropriate flag
616
616
directives : {
617
617
type : NodeTypes . JS_ARRAY_EXPRESSION ,
618
618
elements : [
@@ -945,26 +945,26 @@ describe('compiler: element transform', () => {
945
945
expect ( node . patchFlag ) . toBeUndefined ( )
946
946
947
947
const { node : node2 } = parseWithBind ( `<div>{{ foo }}</div>` )
948
- expect ( node2 . patchFlag ) . toBe ( genFlagText ( PatchFlags . TEXT ) )
948
+ expect ( node2 . patchFlag ) . toBe ( PatchFlags . TEXT )
949
949
950
950
// multiple nodes, merged with optimize text
951
951
const { node : node3 } = parseWithBind ( `<div>foo {{ bar }} baz</div>` )
952
- expect ( node3 . patchFlag ) . toBe ( genFlagText ( PatchFlags . TEXT ) )
952
+ expect ( node3 . patchFlag ) . toBe ( PatchFlags . TEXT )
953
953
} )
954
954
955
955
test ( 'CLASS' , ( ) => {
956
956
const { node } = parseWithBind ( `<div :class="foo" />` )
957
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . CLASS ) )
957
+ expect ( node . patchFlag ) . toBe ( PatchFlags . CLASS )
958
958
} )
959
959
960
960
test ( 'STYLE' , ( ) => {
961
961
const { node } = parseWithBind ( `<div :style="foo" />` )
962
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . STYLE ) )
962
+ expect ( node . patchFlag ) . toBe ( PatchFlags . STYLE )
963
963
} )
964
964
965
965
test ( 'PROPS' , ( ) => {
966
966
const { node } = parseWithBind ( `<div id="foo" :foo="bar" :baz="qux" />` )
967
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . PROPS ) )
967
+ expect ( node . patchFlag ) . toBe ( PatchFlags . PROPS )
968
968
expect ( node . dynamicProps ) . toBe ( `["foo", "baz"]` )
969
969
} )
970
970
@@ -973,7 +973,7 @@ describe('compiler: element transform', () => {
973
973
`<div id="foo" :class="cls" :style="styl" :foo="bar" :baz="qux"/>` ,
974
974
)
975
975
expect ( node . patchFlag ) . toBe (
976
- genFlagText ( [ PatchFlags . CLASS , PatchFlags . STYLE , PatchFlags . PROPS ] ) ,
976
+ PatchFlags . CLASS | PatchFlags . STYLE | PatchFlags . PROPS ,
977
977
)
978
978
expect ( node . dynamicProps ) . toBe ( `["foo", "baz"]` )
979
979
} )
@@ -983,40 +983,40 @@ describe('compiler: element transform', () => {
983
983
const { node } = parseWithBind (
984
984
`<Foo :id="foo" :class="cls" :style="styl" />` ,
985
985
)
986
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . PROPS ) )
986
+ expect ( node . patchFlag ) . toBe ( PatchFlags . PROPS )
987
987
expect ( node . dynamicProps ) . toBe ( `["id", "class", "style"]` )
988
988
} )
989
989
990
990
test ( 'FULL_PROPS (v-bind)' , ( ) => {
991
991
const { node } = parseWithBind ( `<div v-bind="foo" />` )
992
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . FULL_PROPS ) )
992
+ expect ( node . patchFlag ) . toBe ( PatchFlags . FULL_PROPS )
993
993
} )
994
994
995
995
test ( 'FULL_PROPS (dynamic key)' , ( ) => {
996
996
const { node } = parseWithBind ( `<div :[foo]="bar" />` )
997
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . FULL_PROPS ) )
997
+ expect ( node . patchFlag ) . toBe ( PatchFlags . FULL_PROPS )
998
998
} )
999
999
1000
1000
test ( 'FULL_PROPS (w/ others)' , ( ) => {
1001
1001
const { node } = parseWithBind (
1002
1002
`<div id="foo" v-bind="bar" :class="cls" />` ,
1003
1003
)
1004
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . FULL_PROPS ) )
1004
+ expect ( node . patchFlag ) . toBe ( PatchFlags . FULL_PROPS )
1005
1005
} )
1006
1006
1007
1007
test ( 'NEED_PATCH (static ref)' , ( ) => {
1008
1008
const { node } = parseWithBind ( `<div ref="foo" />` )
1009
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . NEED_PATCH ) )
1009
+ expect ( node . patchFlag ) . toBe ( PatchFlags . NEED_PATCH )
1010
1010
} )
1011
1011
1012
1012
test ( 'NEED_PATCH (dynamic ref)' , ( ) => {
1013
1013
const { node } = parseWithBind ( `<div :ref="foo" />` )
1014
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . NEED_PATCH ) )
1014
+ expect ( node . patchFlag ) . toBe ( PatchFlags . NEED_PATCH )
1015
1015
} )
1016
1016
1017
1017
test ( 'NEED_PATCH (custom directives)' , ( ) => {
1018
1018
const { node } = parseWithBind ( `<div v-foo />` )
1019
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . NEED_PATCH ) )
1019
+ expect ( node . patchFlag ) . toBe ( PatchFlags . NEED_PATCH )
1020
1020
} )
1021
1021
1022
1022
test ( 'NEED_PATCH (vnode hooks)' , ( ) => {
@@ -1025,7 +1025,7 @@ describe('compiler: element transform', () => {
1025
1025
cacheHandlers : true ,
1026
1026
} ) . ast
1027
1027
const node = ( root as any ) . children [ 0 ] . codegenNode
1028
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . NEED_PATCH ) )
1028
+ expect ( node . patchFlag ) . toBe ( PatchFlags . NEED_PATCH )
1029
1029
} )
1030
1030
1031
1031
test ( 'script setup inline mode template ref (binding exists)' , ( ) => {
@@ -1120,7 +1120,7 @@ describe('compiler: element transform', () => {
1120
1120
} ,
1121
1121
} )
1122
1122
// should only have props flag
1123
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . PROPS ) )
1123
+ expect ( node . patchFlag ) . toBe ( PatchFlags . PROPS )
1124
1124
1125
1125
const { node : node2 } = parseWithElementTransform (
1126
1126
`<div @keyup="foo" />` ,
@@ -1130,21 +1130,15 @@ describe('compiler: element transform', () => {
1130
1130
} ,
1131
1131
} ,
1132
1132
)
1133
- expect ( node2 . patchFlag ) . toBe (
1134
- genFlagText ( [ PatchFlags . PROPS , PatchFlags . NEED_HYDRATION ] ) ,
1135
- )
1133
+ expect ( node2 . patchFlag ) . toBe ( PatchFlags . PROPS | PatchFlags . NEED_HYDRATION )
1136
1134
} )
1137
1135
1138
1136
test ( 'NEED_HYDRATION for v-bind.prop' , ( ) => {
1139
1137
const { node } = parseWithBind ( `<div v-bind:id.prop="id" />` )
1140
- expect ( node . patchFlag ) . toBe (
1141
- genFlagText ( [ PatchFlags . PROPS , PatchFlags . NEED_HYDRATION ] ) ,
1142
- )
1138
+ expect ( node . patchFlag ) . toBe ( PatchFlags . PROPS | PatchFlags . NEED_HYDRATION )
1143
1139
1144
1140
const { node : node2 } = parseWithBind ( `<div .id="id" />` )
1145
- expect ( node2 . patchFlag ) . toBe (
1146
- genFlagText ( [ PatchFlags . PROPS , PatchFlags . NEED_HYDRATION ] ) ,
1147
- )
1141
+ expect ( node2 . patchFlag ) . toBe ( PatchFlags . PROPS | PatchFlags . NEED_HYDRATION )
1148
1142
} )
1149
1143
1150
1144
// #5870
@@ -1157,9 +1151,7 @@ describe('compiler: element transform', () => {
1157
1151
} ,
1158
1152
} ,
1159
1153
)
1160
- expect ( node . patchFlag ) . toBe (
1161
- genFlagText ( [ PatchFlags . PROPS , PatchFlags . NEED_HYDRATION ] ) ,
1162
- )
1154
+ expect ( node . patchFlag ) . toBe ( PatchFlags . PROPS | PatchFlags . NEED_HYDRATION )
1163
1155
} )
1164
1156
1165
1157
test ( 'should not have PROPS patchflag for constant v-on handlers' , ( ) => {
@@ -1173,7 +1165,7 @@ describe('compiler: element transform', () => {
1173
1165
} ,
1174
1166
} )
1175
1167
// should only have hydration flag
1176
- expect ( node . patchFlag ) . toBe ( genFlagText ( PatchFlags . NEED_HYDRATION ) )
1168
+ expect ( node . patchFlag ) . toBe ( PatchFlags . NEED_HYDRATION )
1177
1169
} )
1178
1170
} )
1179
1171
0 commit comments