Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhe141 committed Aug 29, 2024
1 parent 966b490 commit a87987c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 15 additions & 4 deletions packages/compiler-core/__tests__/transforms/vFor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,26 @@ describe('compiler: v-for', () => {
})

test('the value in binding metadata cannot be used as a parameter.', () => {
const onError = vi.fn()
const onError1 = vi.fn()
parseWithForTransform('<Comp v-for="Comp of list" />', {
onError: onError,
onError: onError1,
bindingMetadata: {
Comp: BindingTypes.SETUP_CONST,
},
})
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect(onError1).toHaveBeenCalledTimes(1)
expect(onError1).toHaveBeenCalledWith(
expect.objectContaining({
code: ErrorCodes.X_V_FOR_PARAMS,
}),
)

const onError2 = vi.fn()
parseWithForTransform('<Comp v-for="Comp of list" />', {
onError: onError2,
})
expect(onError2).toHaveBeenCalledTimes(1)
expect(onError2).toHaveBeenCalledWith(
expect.objectContaining({
code: ErrorCodes.X_V_FOR_PARAMS,
}),
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-core/src/transforms/vFor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ function findTag(
node: VNodeCall | ElementNode,
name: string,
): VNodeCall | ElementNode | undefined {
if (node.tag === name) return node
if (node.tag === `$setup["${name}"]` || node.tag === `_component_${name}`)
return node
if (node.children) {
const children = node.children as TemplateChildNode[]
for (let i = 0; i < children.length; i++) {
Expand Down

0 comments on commit a87987c

Please sign in to comment.