feat(ssr): render portals (#714)

This commit is contained in:
Dmitry Sharshakov
2020-02-16 01:41:20 +03:00
committed by GitHub
parent aa09f01a1e
commit e495fa4a18
3 changed files with 93 additions and 11 deletions

View File

@@ -5,11 +5,16 @@ import {
withScopeId,
resolveComponent,
ComponentOptions,
Portal,
ref,
defineComponent
} from 'vue'
import { escapeHtml, mockWarn } from '@vue/shared'
import { renderToString, renderComponent } from '../src/renderToString'
import {
renderToString,
renderComponent,
SSRContext
} from '../src/renderToString'
import { ssrRenderSlot } from '../src/helpers/ssrRenderSlot'
mockWarn()
@@ -508,6 +513,21 @@ describe('ssr: renderToString', () => {
})
})
test('portal', async () => {
const ctx: SSRContext = {}
await renderToString(
h(
Portal,
{
target: `#target`
},
h('span', 'hello')
),
ctx
)
expect(ctx.portals!['#target']).toBe('<span>hello</span>')
})
describe('scopeId', () => {
// note: here we are only testing scopeId handling for vdom serialization.
// compiled srr render functions will include scopeId directly in strings.