@@ -53,28 +53,32 @@ module.exports = {
5353 /**
5454 * `casing.camelCase()` converts the beginning to lowercase,
5555 * 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
5757 * @param {string } str
5858 */
5959 function camelize ( str ) {
6060 return str . replace ( / - ( \w ) / g, ( _ , c ) => ( c ? c . toUpperCase ( ) : '' ) )
6161 }
6262 /**
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
6464 * @param {string } name
6565 */
66- function markElementVariableAsUsed ( name ) {
66+ function markSetupReferenceVariableAsUsed ( name ) {
6767 if ( scriptVariableNames . has ( name ) ) {
6868 context . markVariableAsUsed ( name )
69+ return true
6970 }
7071 const camelName = camelize ( name )
7172 if ( scriptVariableNames . has ( camelName ) ) {
7273 context . markVariableAsUsed ( camelName )
74+ return true
7375 }
7476 const pascalName = casing . capitalize ( camelName )
7577 if ( scriptVariableNames . has ( pascalName ) ) {
7678 context . markVariableAsUsed ( pascalName )
79+ return true
7780 }
81+ return false
7882 }
7983
8084 return utils . defineTemplateBodyVisitor (
@@ -97,14 +101,21 @@ module.exports = {
97101 ) {
98102 return
99103 }
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+ }
101112 } ,
102113 /** @param {VDirective } node */
103114 'VAttribute[directive=true]' ( node ) {
104115 if ( utils . isBuiltInDirectiveName ( node . key . name . name ) ) {
105116 return
106117 }
107- markElementVariableAsUsed ( `v-${ node . key . name . rawName } ` )
118+ markSetupReferenceVariableAsUsed ( `v-${ node . key . name . rawName } ` )
108119 } ,
109120 /** @param {VAttribute } node */
110121 'VAttribute[directive=false]' ( node ) {
0 commit comments