Skip to content

Commit ee65aa1

Browse files
hchlqyyx990803
authored andcommitted
fix(compiler-core): add test case for v-for source with spaces
1 parent baad119 commit ee65aa1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ 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("state ['my items']")
214+
})
205215
})
206216

207217
describe('errors', () => {
@@ -265,16 +275,6 @@ describe('compiler: v-for', () => {
265275
)
266276
})
267277

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-
278278
test('missing value', () => {
279279
const onError = vi.fn()
280280
parseWithForTransform('<span v-for="in items" />', { onError })

0 commit comments

Comments
 (0)