Skip to content

Commit

Permalink
feat: v-text
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Nov 24, 2023
1 parent 74b4328 commit dc3bc70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
8 changes: 8 additions & 0 deletions packages/compiler-vapor/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}>`
}

Expand Down Expand Up @@ -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
}
}

Expand Down
3 changes: 2 additions & 1 deletion playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down

0 comments on commit dc3bc70

Please sign in to comment.