From 1b4efc30c3c83ed5ee86fb627b8fe355949b636a Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 21 Nov 2023 22:27:35 +0800 Subject: [PATCH] wip: should parse sfc template with lang=html --- packages/compiler-core/src/parser/index.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/compiler-core/src/parser/index.ts b/packages/compiler-core/src/parser/index.ts index 99c7e0879..789a658f8 100644 --- a/packages/compiler-core/src/parser/index.ts +++ b/packages/compiler-core/src/parser/index.ts @@ -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) {