@@ -13,7 +13,7 @@ import {
13
13
ASTText ,
14
14
CompilerOptions
15
15
} from 'types/compiler'
16
- import { BindingMetadata } from 'sfc/types'
16
+ import { BindingMetadata , BindingTypes } from 'sfc/types'
17
17
18
18
type TransformFunction = ( el : ASTElement , code : string ) => string
19
19
type DataGenFunction = ( el : ASTElement ) => string
@@ -103,10 +103,34 @@ export function genElement(el: ASTElement, state: CodegenState): string {
103
103
// check if this is a component in <script setup>
104
104
const bindings = state . options . bindings
105
105
if ( bindings && bindings . __isScriptSetup !== false ) {
106
- tag =
107
- checkBindingType ( bindings , el . tag ) ||
108
- checkBindingType ( bindings , camelize ( el . tag ) ) ||
109
- checkBindingType ( bindings , capitalize ( camelize ( el . tag ) ) )
106
+ const camelName = camelize ( el . tag )
107
+ const PascalName = capitalize ( camelName )
108
+ const checkType = ( type ) => {
109
+ if ( bindings [ el . tag ] === type ) {
110
+ return el . tag
111
+ }
112
+ if ( bindings [ camelName ] === type ) {
113
+ return camelName
114
+ }
115
+ if ( bindings [ PascalName ] === type ) {
116
+ return PascalName
117
+ }
118
+ }
119
+
120
+ const fromConst =
121
+ checkType ( BindingTypes . SETUP_CONST ) ||
122
+ checkType ( BindingTypes . SETUP_REACTIVE_CONST )
123
+ if ( fromConst ) {
124
+ tag = fromConst
125
+ } else {
126
+ const fromMaybeRef =
127
+ checkType ( BindingTypes . SETUP_LET ) ||
128
+ checkType ( BindingTypes . SETUP_REF ) ||
129
+ checkType ( BindingTypes . SETUP_MAYBE_REF )
130
+ if ( fromMaybeRef ) {
131
+ tag = fromMaybeRef
132
+ }
133
+ }
110
134
}
111
135
if ( ! tag ) tag = `'${ el . tag } '`
112
136
0 commit comments