From dc3bc7016ec99cb38dce3bf3eb9ef428b79370ae 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, 24 Nov 2023 14:48:51 +0800 Subject: [PATCH] feat: v-text --- README.md | 2 +- packages/compiler-vapor/src/transform.ts | 8 ++++++++ playground/src/App.vue | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 93bfdc129..f1100c703 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ See the To-do list below or `// TODO` comments in code (`compiler-vapor` and `ru - [ ] `v-for` - [ ] `v-once` - [x] `v-html` - - [ ] `v-text` + - [x] `v-text` - [ ] `v-show` - [ ] `v-pre` - [ ] `v-cloak` diff --git a/packages/compiler-vapor/src/transform.ts b/packages/compiler-vapor/src/transform.ts index 8436092c7..a7bd65e2b 100644 --- a/packages/compiler-vapor/src/transform.ts +++ b/packages/compiler-vapor/src/transform.ts @@ -216,6 +216,7 @@ function transformElement(ctx: TransformContext) { if (children.length) transformChildren(ctx) // TODO remove unnecessary close tag + // TODO: [bug] self closing
if (!node.isSelfClosing) ctx.template += `` } @@ -354,6 +355,13 @@ function transformProp( element: ctx.getElementId(), }) break + case 'text': + ctx.registerEffect(expr, { + type: IRNodeTypes.SET_TEXT, + loc: node.loc, + element: ctx.getElementId(), + }) + break } } diff --git a/playground/src/App.vue b/playground/src/App.vue index cb0887d99..5dbfb1f55 100644 --- a/playground/src/App.vue +++ b/playground/src/App.vue @@ -29,7 +29,8 @@ globalThis.html = html
-
+
+