]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-vapor): don't setText for root element
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Fri, 19 Jan 2024 14:50:07 +0000 (22:50 +0800)
committer三咲智子 Kevin Deng <sxzz@sxzz.moe>
Fri, 19 Jan 2024 14:50:12 +0000 (22:50 +0800)
packages/compiler-vapor/src/transforms/transformInterpolation.ts
playground/src/dynamic.vue [new file with mode: 0644]
playground/src/todo-mvc.vue [new file with mode: 0644]

index 02b4f0208f0a6589da343451e2244e5d7e844c03..ac1a7142086e5b01799550877521912ddbba4f7d 100644 (file)
@@ -9,8 +9,9 @@ export const transformInterpolation: NodeTransform = (node, ctx) => {
   const parentChildren = ctx.parent ? ctx.parent.node.children : []
   const isFirst = ctx.index === 0
   const isLast = ctx.index === parentChildren.length - 1
+  const isRoot = ctx.parent === ctx.root
 
-  if (isFirst && isLast) {
+  if (isFirst && isLast && !isRoot) {
     const parent = ctx.parent!
     const parentId = parent.reference()
     ctx.registerEffect(
diff --git a/playground/src/dynamic.vue b/playground/src/dynamic.vue
new file mode 100644 (file)
index 0000000..75bd648
--- /dev/null
@@ -0,0 +1 @@
+<template>{{ '1' }}</template>
diff --git a/playground/src/todo-mvc.vue b/playground/src/todo-mvc.vue
new file mode 100644 (file)
index 0000000..1d9ccbd
--- /dev/null
@@ -0,0 +1,11 @@
+<script setup lang="ts">
+import { ref } from 'vue/vapor'
+
+interface Task {
+  title: string
+  completed: boolean
+}
+const tasks = ref<Task[]>([])
+</script>
+
+<template>{{ tasks }}</template>