@@ -71,8 +71,8 @@ module.exports = {
71
71
* @returns {IterableIterator<Fix> } fix data
72
72
*/
73
73
function * fixSlotToVSlot ( fixer , slotAttr , slotName , vBind ) {
74
- const element = slotAttr . parent
75
- const scopeAttr = element . attributes . find (
74
+ const startTag = slotAttr . parent
75
+ const scopeAttr = startTag . attributes . find (
76
76
( attr ) =>
77
77
attr . directive === true &&
78
78
attr . key . name &&
@@ -89,9 +89,21 @@ module.exports = {
89
89
: ''
90
90
91
91
const replaceText = `v-slot${ nameArgument } ${ scopeValue } `
92
- yield fixer . replaceText ( slotAttr || scopeAttr , replaceText )
93
- if ( slotAttr && scopeAttr ) {
94
- yield fixer . remove ( scopeAttr )
92
+
93
+ const element = startTag . parent
94
+ if ( element . name === 'template' ) {
95
+ yield fixer . replaceText ( slotAttr || scopeAttr , replaceText )
96
+ if ( slotAttr && scopeAttr ) {
97
+ yield fixer . remove ( scopeAttr )
98
+ }
99
+ } else {
100
+ yield fixer . remove ( slotAttr || scopeAttr )
101
+ if ( slotAttr && scopeAttr ) {
102
+ yield fixer . remove ( scopeAttr )
103
+ }
104
+
105
+ yield fixer . insertTextBefore ( element , `<template ${ replaceText } >\n` )
106
+ yield fixer . insertTextAfter ( element , `\n</template>` )
95
107
}
96
108
}
97
109
/**
0 commit comments