@@ -34,22 +34,22 @@ function compileWithVBind(
34
34
return { ir, code }
35
35
}
36
36
37
- describe ( 'compiler: transform v-bind' , ( ) => {
37
+ describe ( 'compiler v-bind' , ( ) => {
38
38
test ( 'basic' , ( ) => {
39
- const { ir : node , code } = compileWithVBind ( `<div v-bind:id="id"/>` )
39
+ const { ir, code } = compileWithVBind ( `<div v-bind:id="id"/>` )
40
40
41
- expect ( node . dynamic . children [ 0 ] ) . toMatchObject ( {
41
+ expect ( ir . dynamic . children [ 0 ] ) . toMatchObject ( {
42
42
id : 1 ,
43
43
referenced : true ,
44
44
} )
45
- expect ( node . template [ 0 ] ) . toMatchObject ( {
45
+ expect ( ir . template [ 0 ] ) . toMatchObject ( {
46
46
type : IRNodeTypes . TEMPLATE_FACTORY ,
47
47
template : '<div></div>' ,
48
48
} )
49
- expect ( node . effect ) . lengthOf ( 1 )
50
- expect ( node . effect [ 0 ] . expressions ) . lengthOf ( 1 )
51
- expect ( node . effect [ 0 ] . operations ) . lengthOf ( 1 )
52
- expect ( node . effect [ 0 ] ) . toMatchObject ( {
49
+ expect ( ir . effect ) . lengthOf ( 1 )
50
+ expect ( ir . effect [ 0 ] . expressions ) . lengthOf ( 1 )
51
+ expect ( ir . effect [ 0 ] . operations ) . lengthOf ( 1 )
52
+ expect ( ir . effect [ 0 ] ) . toMatchObject ( {
53
53
expressions : [
54
54
{
55
55
type : NodeTypes . SIMPLE_EXPRESSION ,
@@ -89,9 +89,9 @@ describe('compiler: transform v-bind', () => {
89
89
} )
90
90
91
91
test ( 'no expression' , ( ) => {
92
- const { ir : node , code } = compileWithVBind ( `<div v-bind:id />` )
92
+ const { ir, code } = compileWithVBind ( `<div v-bind:id />` )
93
93
94
- expect ( node . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
94
+ expect ( ir . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
95
95
type : IRNodeTypes . SET_PROP ,
96
96
key : {
97
97
content : `id` ,
@@ -116,9 +116,9 @@ describe('compiler: transform v-bind', () => {
116
116
} )
117
117
118
118
test ( 'no expression (shorthand)' , ( ) => {
119
- const { ir : node , code } = compileWithVBind ( `<div :camel-case />` )
119
+ const { ir, code } = compileWithVBind ( `<div :camel-case />` )
120
120
121
- expect ( node . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
121
+ expect ( ir . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
122
122
type : IRNodeTypes . SET_PROP ,
123
123
key : {
124
124
content : `camel-case` ,
@@ -137,8 +137,8 @@ describe('compiler: transform v-bind', () => {
137
137
} )
138
138
139
139
test ( 'dynamic arg' , ( ) => {
140
- const { ir : node , code } = compileWithVBind ( `<div v-bind:[id]="id"/>` )
141
- expect ( node . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
140
+ const { ir, code } = compileWithVBind ( `<div v-bind:[id]="id"/>` )
141
+ expect ( ir . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
142
142
type : IRNodeTypes . SET_PROP ,
143
143
element : 1 ,
144
144
key : {
@@ -159,7 +159,7 @@ describe('compiler: transform v-bind', () => {
159
159
160
160
test ( 'should error if empty expression' , ( ) => {
161
161
const onError = vi . fn ( )
162
- const { ir : node , code } = compileWithVBind ( `<div v-bind:arg="" />` , {
162
+ const { ir, code } = compileWithVBind ( `<div v-bind:arg="" />` , {
163
163
onError,
164
164
} )
165
165
@@ -170,7 +170,7 @@ describe('compiler: transform v-bind', () => {
170
170
end : { line : 1 , column : 19 } ,
171
171
} ,
172
172
} )
173
- expect ( node . template [ 0 ] ) . toMatchObject ( {
173
+ expect ( ir . template [ 0 ] ) . toMatchObject ( {
174
174
type : IRNodeTypes . TEMPLATE_FACTORY ,
175
175
template : '<div arg=""></div>' ,
176
176
} )
@@ -180,11 +180,9 @@ describe('compiler: transform v-bind', () => {
180
180
} )
181
181
182
182
test ( '.camel modifier' , ( ) => {
183
- const { ir : node , code } = compileWithVBind (
184
- `<div v-bind:foo-bar.camel="id"/>` ,
185
- )
183
+ const { ir, code } = compileWithVBind ( `<div v-bind:foo-bar.camel="id"/>` )
186
184
187
- expect ( node . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
185
+ expect ( ir . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
188
186
key : {
189
187
content : `fooBar` ,
190
188
isStatic : true ,
@@ -200,9 +198,9 @@ describe('compiler: transform v-bind', () => {
200
198
} )
201
199
202
200
test ( '.camel modifier w/ no expression' , ( ) => {
203
- const { ir : node , code } = compileWithVBind ( `<div v-bind:foo-bar.camel />` )
201
+ const { ir, code } = compileWithVBind ( `<div v-bind:foo-bar.camel />` )
204
202
205
- expect ( node . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
203
+ expect ( ir . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
206
204
key : {
207
205
content : `fooBar` ,
208
206
isStatic : true ,
@@ -219,11 +217,9 @@ describe('compiler: transform v-bind', () => {
219
217
} )
220
218
221
219
test ( '.camel modifier w/ dynamic arg' , ( ) => {
222
- const { ir : node , code } = compileWithVBind (
223
- `<div v-bind:[foo].camel="id"/>` ,
224
- )
220
+ const { ir, code } = compileWithVBind ( `<div v-bind:[foo].camel="id"/>` )
225
221
226
- expect ( node . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
222
+ expect ( ir . effect [ 0 ] . operations [ 0 ] ) . toMatchObject ( {
227
223
runtimeCamelize : true ,
228
224
key : {
229
225
content : `foo` ,
0 commit comments