]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat: v-text
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Fri, 24 Nov 2023 06:48:51 +0000 (14:48 +0800)
committer三咲智子 Kevin Deng <sxzz@sxzz.moe>
Fri, 24 Nov 2023 06:48:51 +0000 (14:48 +0800)
README.md
packages/compiler-vapor/src/transform.ts
playground/src/App.vue

index 93bfdc129e488e8c80f5051e59c2b3f6c2bdaaba..f1100c7033180c6e77a16ee5a3e5e2240933fcbd 100644 (file)
--- 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`
index 8436092c7c29cf2fe89a9df4faa05dd7d2ebbbda..a7bd65e2b1af70f042c8ef685afb395f60a647ab 100644 (file)
@@ -216,6 +216,7 @@ function transformElement(ctx: TransformContext<ElementNode>) {
   if (children.length) transformChildren(ctx)
 
   // TODO remove unnecessary close tag
+  // TODO: [bug] self closing <div />
   if (!node.isSelfClosing) ctx.template += `</${tag}>`
 }
 
@@ -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
   }
 }
 
index cb0887d99ee31588416fdf3a7ce58199be505698..5dbfb1f55b45188e39a5569d39745fa0931a8664 100644 (file)
@@ -29,7 +29,8 @@ globalThis.html = html
       <button @click="inc">inc</button>
       <button @click="dec">dec</button>
     </div>
-    <div v-html="html" />
+    <div v-html="html"></div>
+    <div v-text="html"></div>
   </div>
 </template>