File tree 3 files changed +20
-9
lines changed
3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ import {
22
22
isArray ,
23
23
NOOP ,
24
24
PatchFlags ,
25
- PatchFlagNames
25
+ PatchFlagNames ,
26
+ EMPTY_OBJ
26
27
} from '@vue/shared'
27
28
import { defaultOnError } from './errors'
28
29
import {
@@ -122,7 +123,7 @@ export function createTransformContext(
122
123
scopeId = null ,
123
124
ssr = false ,
124
125
ssrCssVars = `` ,
125
- bindingMetadata = { } ,
126
+ bindingMetadata = EMPTY_OBJ ,
126
127
onError = defaultOnError
127
128
} : TransformOptions
128
129
) : TransformContext {
Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ import {
26
26
isSymbol ,
27
27
isOn ,
28
28
isObject ,
29
- isReservedProp
29
+ isReservedProp ,
30
+ capitalize ,
31
+ camelize ,
32
+ EMPTY_OBJ
30
33
} from '@vue/shared'
31
34
import { createCompilerError , ErrorCodes } from '../errors'
32
35
import {
@@ -246,8 +249,15 @@ export function resolveComponentType(
246
249
}
247
250
248
251
// 3. user component (from setup bindings)
249
- if ( context . bindingMetadata [ tag ] === 'setup' ) {
250
- return `$setup[${ JSON . stringify ( tag ) } ]`
252
+ let tagFromSetup = tag
253
+ const bindings = context . bindingMetadata
254
+ if (
255
+ bindings !== EMPTY_OBJ &&
256
+ ( bindings [ tagFromSetup ] === 'setup' ||
257
+ bindings [ ( tagFromSetup = camelize ( tag ) ) ] === 'setup' ||
258
+ bindings [ ( tagFromSetup = capitalize ( camelize ( tag ) ) ) ] === 'setup' )
259
+ ) {
260
+ return `$setup[${ JSON . stringify ( tagFromSetup ) } ]`
251
261
}
252
262
253
263
// 4. user component (resolve)
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ const hasWarned: Record<string, boolean> = {}
41
41
function warnOnce ( msg : string ) {
42
42
if ( ! hasWarned [ msg ] ) {
43
43
hasWarned [ msg ] = true
44
- console . log ( `\n\ x1b[33m[@vue/compiler-sfc] %s\x1b[0m\n` , msg )
44
+ console . log ( `\x1b[33m[@vue/compiler-sfc] %s\x1b[0m\n` , msg )
45
45
}
46
46
}
47
47
@@ -59,7 +59,7 @@ export function compileScript(
59
59
if ( __DEV__ && ! __TEST__ && scriptSetup ) {
60
60
warnOnce (
61
61
`<script setup> is still an experimental proposal.\n` +
62
- `Follow https://github.com/vuejs/rfcs/pull/227 for its status .`
62
+ `Follow its status at https://github.com/vuejs/rfcs/pull/227.`
63
63
)
64
64
}
65
65
@@ -461,9 +461,9 @@ export function compileScript(
461
461
) {
462
462
if ( enableRefSugar ) {
463
463
warnOnce (
464
- `ref: sugar is still an experimental proposal and is not\n ` +
464
+ `ref: sugar is still an experimental proposal and is not ` +
465
465
`guaranteed to be a part of <script setup>.\n` +
466
- `Follow its status at https://github.com/vuejs/rfcs/pull/228`
466
+ `Follow its status at https://github.com/vuejs/rfcs/pull/228. `
467
467
)
468
468
s . overwrite (
469
469
node . label . start ! + startOffset ,
You can’t perform that action at this time.
0 commit comments