@@ -8,6 +8,21 @@ module.exports = {
8
8
supported : '2.5.0' ,
9
9
createTemplateBodyVisitor ( context , { fixToUpgrade } = { } ) {
10
10
const sourceCode = context . getSourceCode ( )
11
+
12
+ /**
13
+ * Checks whether the given node can convert to the `v-slot`.
14
+ * @param {VAttribute | null } slotAttr node of `slot`
15
+ * @returns {boolean } `true` if the given node can convert to the `v-slot`
16
+ */
17
+ function canConvertToVSlot ( slotAttr ) {
18
+ if ( ! slotAttr || ! slotAttr . value ) {
19
+ return true
20
+ }
21
+ const slotName = slotAttr . value . value
22
+ // If non-Latin characters are included it can not be converted.
23
+ return ! / [ ^ a - z ] / i. test ( slotName )
24
+ }
25
+
11
26
/**
12
27
* Convert to `v-slot`.
13
28
* @param {object } fixer fixer
@@ -16,7 +31,7 @@ module.exports = {
16
31
* @returns {* } fix data
17
32
*/
18
33
function fixSlotToVSlot ( fixer , slotAttr , scopeAttr ) {
19
- const nameArgument = slotAttr && slotAttr . value && slotAttr && slotAttr . value . value
34
+ const nameArgument = slotAttr && slotAttr . value && slotAttr . value . value
20
35
? `:${ slotAttr . value . value } `
21
36
: ''
22
37
const scopeValue = scopeAttr && scopeAttr . value
@@ -47,6 +62,9 @@ module.exports = {
47
62
const element = scopeAttr . parent
48
63
const slotAttr = element . attributes
49
64
. find ( attr => attr . directive === false && attr . key . name === 'slot' )
65
+ if ( ! canConvertToVSlot ( slotAttr ) ) {
66
+ return null
67
+ }
50
68
return fixSlotToVSlot ( fixer , slotAttr , scopeAttr )
51
69
}
52
70
: null
0 commit comments