]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: should parse sfc template with lang=html
authorEvan You <yyx990803@gmail.com>
Tue, 21 Nov 2023 14:27:35 +0000 (22:27 +0800)
committerEvan You <yyx990803@gmail.com>
Sat, 25 Nov 2023 08:18:29 +0000 (16:18 +0800)
packages/compiler-core/src/parser/index.ts

index 99c7e0879cd56e13d2babd9f0aa11038590ef238..789a658f876b11d190f60ae87ab3beddd9a8ef46 100644 (file)
@@ -179,10 +179,10 @@ const tokenizer = new Tokenizer(stack, {
         raw === '.' || raw === ':'
           ? 'bind'
           : raw === '@'
-          ? 'on'
-          : raw === '#'
-          ? 'slot'
-          : raw.slice(2)
+            ? 'on'
+            : raw === '#'
+              ? 'slot'
+              : raw.slice(2)
       currentProp = {
         type: NodeTypes.DIRECTIVE,
         name,
@@ -296,10 +296,11 @@ const tokenizer = new Tokenizer(stack, {
                 : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
           }
           if (
-            currentAttrValue &&
             tokenizer.inSFCRoot &&
             currentElement.tag === 'template' &&
-            currentProp.name === 'lang'
+            currentProp.name === 'lang' &&
+            currentAttrValue &&
+            currentAttrValue !== 'html'
           ) {
             // SFC root template with preprocessor lang, force tokenizer to
             // RCDATA mode
@@ -765,8 +766,8 @@ export function baseParse(input: string, options?: ParserOptions): RootNode {
     currentOptions.parseMode === 'html'
       ? ParseMode.HTML
       : currentOptions.parseMode === 'sfc'
-      ? ParseMode.SFC
-      : ParseMode.BASE
+        ? ParseMode.SFC
+        : ParseMode.BASE
 
   const delimiters = options?.delimiters
   if (delimiters) {