wip: should parse sfc template with lang=html

This commit is contained in:
Evan You 2023-11-21 22:27:35 +08:00
parent b59eabdc0d
commit 1b4efc30c3
1 changed files with 9 additions and 8 deletions

View File

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