From: Evan You Date: Wed, 15 Nov 2023 15:55:50 +0000 (+0800) Subject: wip: pre tag handling X-Git-Tag: v3.4.0-alpha.2~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1a1f680536364a234bfb5ecd0b100b0975154640;p=thirdparty%2Fvuejs%2Fcore.git wip: pre tag handling --- diff --git a/packages/compiler-core/src/parser/index.ts b/packages/compiler-core/src/parser/index.ts index 7ced0f4301..34da397a34 100644 --- a/packages/compiler-core/src/parser/index.ts +++ b/packages/compiler-core/src/parser/index.ts @@ -274,10 +274,13 @@ function emitOpenTag(name: string, start: number) { function endOpenTag(end: number) { addNode(currentElement!) const name = currentElement!.tag - if (!currentOptions.isVoidTag(name)) { - stack.unshift(currentElement!) - } else { + if (currentOptions.isPreTag(name)) { + inPre++ + } + if (currentOptions.isVoidTag(name)) { onCloseTag(currentElement!, end) + } else { + stack.unshift(currentElement!) } currentElement = null } @@ -319,6 +322,9 @@ function onCloseTag(el: ElementNode, end: number) { el.loc.end = tokenizer.getPos(end + offset + 1) // whitepsace management el.children = condenseWhitespace(el.children) + if (currentOptions.isPreTag(el.tag)) { + inPre-- + } } const windowsNewlineRE = /\r\n/g