feat: v-text

This commit is contained in:
三咲智子 Kevin Deng 2023-11-24 14:48:51 +08:00
parent 74b4328337
commit dc3bc7016e
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
3 changed files with 11 additions and 2 deletions

View File

@ -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`

View 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
}
}

View 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>