Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1381,4 +1381,14 @@ describe('compiler: element transform', () => {
],
})
})

test('resolveSetupReference handle `kebab-case` component', () => {
const { node } = parseWithElementTransform(`<view-component/>`, {
isNativeTag: () => false,
bindingMetadata: {
ViewComponent: BindingTypes.SETUP_CONST,
},
})
expect(node.tag).toBe(`$setup["ViewComponent"]`)
})
})
6 changes: 3 additions & 3 deletions packages/compiler-core/src/transforms/transformElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,12 @@ function resolveSetupReference(name: string, context: TransformContext) {
if (bindings[name] === type) {
return name
}
if (bindings[camelName] === type) {
return camelName
}
if (bindings[PascalName] === type) {
return PascalName
}
if (bindings[camelName] === type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the right fix.
consider:

import viewComponent from '/src/components/ViewComponent.vue' // v is lowercase
async function ViewComponent(index) { // V is uppercase

}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review, I will try to modify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But after thinking about it, I still think that such a tag should match PascalName, and the editor seems to match it in this way.

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, PascalName is recommended in the document, but this actual a breaking change.

return camelName
}
}

const fromConst =
Expand Down