Просмотр исходного кода

wip: warn against `<template functional>`

Evan You 5 лет назад
Родитель
Сommit
467076361a
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      packages/compiler-sfc/src/parse.ts

+ 12 - 0
packages/compiler-sfc/src/parse.ts

@@ -155,6 +155,18 @@ export function parse(
             false
           ) as SFCTemplateBlock)
           templateBlock.ast = node
+
+          // warn against 2.x <template functional>
+          if (templateBlock.attrs.functional) {
+            const err = new SyntaxError(
+              `<template functional> is no longer supported in Vue 3, since ` +
+                `functional components no longer have significant performance ` +
+                `difference from stateful ones. Just use a normal <template> ` +
+                `instead.`
+            ) as CompilerError
+            err.loc = node.props.find(p => p.name === 'functional')!.loc
+            errors.push(err)
+          }
         } else {
           errors.push(createDuplicateBlockError(node))
         }