@@ -71,8 +71,8 @@ module.exports = {
7171 * @returns {IterableIterator<Fix> } fix data
7272 */
7373 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 (
7676 ( attr ) =>
7777 attr . directive === true &&
7878 attr . key . name &&
@@ -89,9 +89,21 @@ module.exports = {
8989 : ''
9090
9191 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>` )
95107 }
96108 }
97109 /**
0 commit comments