From 10f8cb4351002fa57c453dc7c29aa75d53318ba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Fri, 19 Jan 2024 22:50:07 +0800 Subject: [PATCH] fix(compiler-vapor): don't setText for root element --- .../src/transforms/transformInterpolation.ts | 3 ++- playground/src/dynamic.vue | 1 + playground/src/todo-mvc.vue | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 playground/src/dynamic.vue create mode 100644 playground/src/todo-mvc.vue diff --git a/packages/compiler-vapor/src/transforms/transformInterpolation.ts b/packages/compiler-vapor/src/transforms/transformInterpolation.ts index 02b4f0208..ac1a71420 100644 --- a/packages/compiler-vapor/src/transforms/transformInterpolation.ts +++ b/packages/compiler-vapor/src/transforms/transformInterpolation.ts @@ -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 index 000000000..75bd64837 --- /dev/null +++ b/playground/src/dynamic.vue @@ -0,0 +1 @@ + diff --git a/playground/src/todo-mvc.vue b/playground/src/todo-mvc.vue new file mode 100644 index 000000000..1d9ccbd80 --- /dev/null +++ b/playground/src/todo-mvc.vue @@ -0,0 +1,11 @@ + + +