fix: remove get children when no dynamic node
This commit is contained in:
parent
b70aa0a9a0
commit
74031bac34
|
@ -0,0 +1,23 @@
|
|||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`comile > bindings 1`] = `
|
||||
"import { watchEffect } from 'vue'
|
||||
import { template, setText } from 'vue/vapor'
|
||||
const t0 = template(\`<div></div>\`)
|
||||
export function render() {
|
||||
const root = t0()
|
||||
watchEffect(() => {
|
||||
setText(n0, undefined, count.value)
|
||||
})
|
||||
return root
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`comile > static template 1`] = `
|
||||
"import { template } from 'vue/vapor'
|
||||
const t0 = template(\`<div><p>hello</p><input></div>\`)
|
||||
export function render() {
|
||||
const root = t0()
|
||||
return root
|
||||
}"
|
||||
`;
|
|
@ -1,6 +1,6 @@
|
|||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`basic 1`] = `
|
||||
exports[`fixtures 1`] = `
|
||||
"import { defineComponent as _defineComponent } from 'vue'
|
||||
import { watchEffect } from 'vue'
|
||||
import { template, insert, setText, on, setHtml } from 'vue/vapor'
|
|
@ -0,0 +1,24 @@
|
|||
import { BindingTypes } from '@vue/compiler-dom'
|
||||
import { compile } from '../src'
|
||||
|
||||
describe('comile', () => {
|
||||
it('static template', () => {
|
||||
const { code } = compile(
|
||||
`<div>
|
||||
<p>hello</p>
|
||||
<input />
|
||||
</div>`,
|
||||
{},
|
||||
)
|
||||
expect(code).matchSnapshot()
|
||||
})
|
||||
|
||||
it('bindings', () => {
|
||||
const { code } = compile(`<div>{{ count }}</div>`, {
|
||||
bindingMetadata: {
|
||||
count: BindingTypes.SETUP_REF,
|
||||
},
|
||||
})
|
||||
expect(code).matchSnapshot()
|
||||
})
|
||||
})
|
|
@ -1,9 +1,8 @@
|
|||
import * as CompilerVapor from '../src'
|
||||
// import * as CompilerDOM from '@vue/compiler-dom'
|
||||
import { parse, compileScript } from '@vue/compiler-sfc'
|
||||
import source from './fixtures/counter.vue?raw'
|
||||
|
||||
test('basic', async () => {
|
||||
test('fixtures', async () => {
|
||||
const { descriptor } = parse(source, { compiler: CompilerVapor })
|
||||
const script = compileScript(descriptor, {
|
||||
id: 'counter.vue',
|
|
@ -29,7 +29,7 @@ export function generate(
|
|||
|
||||
// TODO multiple-template
|
||||
code += `const root = t0()\n`
|
||||
if (ir.children[0]) {
|
||||
if (ir.children[0] && Object.keys(ir.children[0].children).length) {
|
||||
code += `const {${genChildren(ir.children[0].children)}} = children(root)\n`
|
||||
vaporHelpers.add('children')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue