Skip to content

Commit baad119

Browse files
hchlqyyx990803
authored andcommitted
fix(compiler-core): handle v-for source with spaces
1 parent 4674ae6 commit baad119

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/compiler-core/__tests__/transforms/vFor.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ describe('compiler: v-for', () => {
265265
)
266266
})
267267

268+
test('source containing string expression with spaces', () => {
269+
const { node: forNode } = parseWithForTransform(
270+
`<span v-for="item in state ['my items']" />`
271+
)
272+
expect(forNode.keyAlias).toBeUndefined()
273+
expect(forNode.objectIndexAlias).toBeUndefined()
274+
expect((forNode.valueAlias as SimpleExpressionNode).content).toBe('item')
275+
expect((forNode.source as SimpleExpressionNode).content).toBe("state ['my items']")
276+
})
277+
268278
test('missing value', () => {
269279
const onError = vi.fn()
270280
parseWithForTransform('<span v-for="in items" />', { onError })

0 commit comments

Comments
 (0)