"import { defineComponent as _defineComponent } from 'vue'
import { watchEffect } from 'vue'
import { template, insert, setText, on, setHtml } from 'vue/vapor'
-const t0 = template(\`<h1 id=\\"title\\">Counter</h1><p>Count: </p><p>Double: </p><button>Increment</button><div/>\`)
+const t0 = template(\`<h1 id=\\"title\\">Counter</h1><p>Count: </p><p>Double: </p><button>Increment</button><div></div><input type=\\"text\\">\`)
import { ref, computed } from 'vue'
const html = '<b>HTML</b>'
type RootIRNode,
IRNodeTypes,
} from './ir'
+import { isVoidTag } from '@vue/shared'
export interface TransformContext<T extends Node = Node> {
node: T
ctx.template += `<${tag}`
props.forEach((prop) => transformProp(prop, ctx))
- ctx.template += node.isSelfClosing ? '/>' : `>`
+ ctx.template += `>`
if (children.length) transformChildren(ctx)
- // TODO remove unnecessary close tag
- // TODO: [bug] self closing <div />
- if (!node.isSelfClosing) ctx.template += `</${tag}>`
+ // TODO remove unnecessary close tag, e.g. if it's the last element of the template
+ if (!node.isSelfClosing || !isVoidTag(tag)) {
+ ctx.template += `</${tag}>`
+ }
}
function transformInterpolation(
<button @click="inc">inc</button>
<button @click="dec">dec</button>
</div>
- <div v-html="html"></div>
- <div v-text="html"></div>
+ <div v-html="html" />
+ <div v-text="html" />
</div>
</template>