]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: pre tag handling
authorEvan You <yyx990803@gmail.com>
Wed, 15 Nov 2023 15:55:50 +0000 (23:55 +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 7ced0f4301db18beb801d37d4be83d46e533c861..34da397a342f268d8b959e85167290f2867a55d0 100644 (file)
@@ -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