@@ -202,6 +202,18 @@ describe('compiler: v-for', () => {
202
202
expect ( forNode . valueAlias ) . toBeUndefined ( )
203
203
expect ( ( forNode . source as SimpleExpressionNode ) . content ) . toBe ( 'items' )
204
204
} )
205
+
206
+ test ( 'source containing string expression with spaces' , ( ) => {
207
+ const { node : forNode } = parseWithForTransform (
208
+ `<span v-for="item in state ['my items']" />` ,
209
+ )
210
+ expect ( forNode . keyAlias ) . toBeUndefined ( )
211
+ expect ( forNode . objectIndexAlias ) . toBeUndefined ( )
212
+ expect ( ( forNode . valueAlias as SimpleExpressionNode ) . content ) . toBe ( 'item' )
213
+ expect ( ( forNode . source as SimpleExpressionNode ) . content ) . toBe (
214
+ "state ['my items']" ,
215
+ )
216
+ } )
205
217
} )
206
218
207
219
describe ( 'errors' , ( ) => {
@@ -253,6 +265,18 @@ describe('compiler: v-for', () => {
253
265
)
254
266
} )
255
267
268
+ test ( 'missing source and have multiple spaces with' , ( ) => {
269
+ const onError = vi . fn ( )
270
+ parseWithForTransform ( '<span v-for="item in " />' , { onError } )
271
+
272
+ expect ( onError ) . toHaveBeenCalledTimes ( 1 )
273
+ expect ( onError ) . toHaveBeenCalledWith (
274
+ expect . objectContaining ( {
275
+ code : ErrorCodes . X_V_FOR_MALFORMED_EXPRESSION ,
276
+ } ) ,
277
+ )
278
+ } )
279
+
256
280
test ( 'missing value' , ( ) => {
257
281
const onError = vi . fn ( )
258
282
parseWithForTransform ( '<span v-for="in items" />' , { onError } )
0 commit comments