@@ -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
@@ -104,10 +104,7 @@ export function genElement(el: ASTElement, state: CodegenState): string {
104
104
// check if this is a component in <script setup>
105
105
const bindings = state . options . bindings
106
106
if ( maybeComponent && bindings && bindings . __isScriptSetup !== false ) {
107
- tag =
108
- checkBindingType ( bindings , el . tag ) ||
109
- checkBindingType ( bindings , camelize ( el . tag ) ) ||
110
- checkBindingType ( bindings , capitalize ( camelize ( el . tag ) ) )
107
+ tag = checkBindingType ( bindings , el . tag )
111
108
}
112
109
if ( ! tag ) tag = `'${ el . tag } '`
113
110
@@ -127,9 +124,32 @@ export function genElement(el: ASTElement, state: CodegenState): string {
127
124
}
128
125
129
126
function checkBindingType ( bindings : BindingMetadata , key : string ) {
130
- const type = bindings [ key ]
131
- if ( type && type . startsWith ( 'setup' ) ) {
132
- return key
127
+ const camelName = camelize ( key )
128
+ const PascalName = capitalize ( camelName )
129
+ const checkType = ( type ) => {
130
+ if ( bindings [ key ] === type ) {
131
+ return key
132
+ }
133
+ if ( bindings [ camelName ] === type ) {
134
+ return camelName
135
+ }
136
+ if ( bindings [ PascalName ] === type ) {
137
+ return PascalName
138
+ }
139
+ }
140
+ const fromConst =
141
+ checkType ( BindingTypes . SETUP_CONST ) ||
142
+ checkType ( BindingTypes . SETUP_REACTIVE_CONST )
143
+ if ( fromConst ) {
144
+ return fromConst
145
+ }
146
+
147
+ const fromMaybeRef =
148
+ checkType ( BindingTypes . SETUP_LET ) ||
149
+ checkType ( BindingTypes . SETUP_REF ) ||
150
+ checkType ( BindingTypes . SETUP_MAYBE_REF )
151
+ if ( fromMaybeRef ) {
152
+ return fromMaybeRef
133
153
}
134
154
}
135
155
0 commit comments