@@ -53,28 +53,32 @@ module.exports = {
53
53
/**
54
54
* `casing.camelCase()` converts the beginning to lowercase,
55
55
* but does not convert the case of the beginning character when converting with Vue3.
56
- * @see https://github.com/vuejs/vue-next/blob/1ffd48a2f5fd3eead3ea29dae668b7ed1c6f6130 /packages/shared/src/index.ts#L116
56
+ * @see https://github.com/vuejs/vue-next/blob/2749c15170ad4913e6530a257db485d4e7ed2283 /packages/shared/src/index.ts#L116
57
57
* @param {string } str
58
58
*/
59
59
function camelize ( str ) {
60
60
return str . replace ( / - ( \w ) / g, ( _ , c ) => ( c ? c . toUpperCase ( ) : '' ) )
61
61
}
62
62
/**
63
- * @see https://github.com/vuejs/vue-next/blob/1ffd48a2f5fd3eead3ea29dae668b7ed1c6f6130 /packages/compiler-core/src/transforms/transformElement.ts#L321
63
+ * @see https://github.com/vuejs/vue-next/blob/2749c15170ad4913e6530a257db485d4e7ed2283 /packages/compiler-core/src/transforms/transformElement.ts#L333
64
64
* @param {string } name
65
65
*/
66
- function markElementVariableAsUsed ( name ) {
66
+ function markSetupReferenceVariableAsUsed ( name ) {
67
67
if ( scriptVariableNames . has ( name ) ) {
68
68
context . markVariableAsUsed ( name )
69
+ return true
69
70
}
70
71
const camelName = camelize ( name )
71
72
if ( scriptVariableNames . has ( camelName ) ) {
72
73
context . markVariableAsUsed ( camelName )
74
+ return true
73
75
}
74
76
const pascalName = casing . capitalize ( camelName )
75
77
if ( scriptVariableNames . has ( pascalName ) ) {
76
78
context . markVariableAsUsed ( pascalName )
79
+ return true
77
80
}
81
+ return false
78
82
}
79
83
80
84
return utils . defineTemplateBodyVisitor (
@@ -97,14 +101,21 @@ module.exports = {
97
101
) {
98
102
return
99
103
}
100
- markElementVariableAsUsed ( node . rawName )
104
+ if ( ! markSetupReferenceVariableAsUsed ( node . rawName ) ) {
105
+ // Check namespace
106
+ // https://github.com/vuejs/vue-next/blob/2749c15170ad4913e6530a257db485d4e7ed2283/packages/compiler-core/src/transforms/transformElement.ts#L304
107
+ const dotIndex = node . rawName . indexOf ( '.' )
108
+ if ( dotIndex > 0 ) {
109
+ markSetupReferenceVariableAsUsed ( node . rawName . slice ( 0 , dotIndex ) )
110
+ }
111
+ }
101
112
} ,
102
113
/** @param {VDirective } node */
103
114
'VAttribute[directive=true]' ( node ) {
104
115
if ( utils . isBuiltInDirectiveName ( node . key . name . name ) ) {
105
116
return
106
117
}
107
- markElementVariableAsUsed ( `v-${ node . key . name . rawName } ` )
118
+ markSetupReferenceVariableAsUsed ( `v-${ node . key . name . rawName } ` )
108
119
} ,
109
120
/** @param {VAttribute } node */
110
121
'VAttribute[directive=false]' ( node ) {
0 commit comments