fix(grid): throw error when there's no children

This commit is contained in:
07akioni 2021-09-28 03:08:34 +08:00
parent b39a798185
commit 4bbc1e8fa0
2 changed files with 16 additions and 3 deletions

View File

@ -169,7 +169,7 @@ export default defineComponent({
let suffixSpan = 0
const maybeSuffixNode =
childrenAndRawSpan[childrenAndRawSpan.length - 1].child
childrenAndRawSpan[childrenAndRawSpan.length - 1]?.child
if (maybeSuffixNode?.props) {
const suffixPropValue = maybeSuffixNode.props?.suffix
if (suffixPropValue !== undefined && suffixPropValue !== false) {

View File

@ -4,15 +4,28 @@
import { h, createSSRApp } from 'vue'
import { renderToString } from '@vue/server-renderer'
import { setup } from '@css-render/vue3-ssr'
import { NGrid } from '../..'
import { NGrid, NGridItem } from '../..'
describe('SSR', () => {
it('works', async () => {
it('works 1', async () => {
const app = createSSRApp(() => <NGrid />)
setup(app)
try {
await renderToString(app)
} catch (e) {
console.log(e)
expect(e).not.toBeTruthy()
}
})
it('works 2', async () => {
const app = createSSRApp(() => (
<NGrid>{{ default: () => <NGridItem /> }}</NGrid>
))
setup(app)
try {
await renderToString(app)
} catch (e) {
console.log(e)
expect(e).not.toBeTruthy()
}
})