@@ -202,6 +202,18 @@ describe('compiler: v-for', () => {
202202 expect ( forNode . valueAlias ) . toBeUndefined ( )
203203 expect ( ( forNode . source as SimpleExpressionNode ) . content ) . toBe ( 'items' )
204204 } )
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+ } )
205217 } )
206218
207219 describe ( 'errors' , ( ) => {
@@ -253,6 +265,18 @@ describe('compiler: v-for', () => {
253265 )
254266 } )
255267
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+
256280 test ( 'missing value' , ( ) => {
257281 const onError = vi . fn ( )
258282 parseWithForTransform ( '<span v-for="in items" />' , { onError } )
0 commit comments