fix(ssr): fix scopeId inheritance across mixed parent chain

fix #3513
This commit is contained in:
Evan You
2021-03-30 18:39:42 -04:00
parent 6cab91dfe8
commit 5e54081d5b
2 changed files with 50 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { createApp, mergeProps, withCtx } from 'vue'
import { createApp, h, mergeProps, withCtx } from 'vue'
import { renderToString } from '../src/renderToString'
import { ssrRenderComponent, ssrRenderAttrs, ssrRenderSlot } from '../src'
@@ -154,4 +154,29 @@ describe('ssr: scopedId runtime behavior', () => {
`</div>`
)
})
// #3513
test('scopeId inheritance across ssr-compiled andn on-ssr compiled parent chain', async () => {
const Child = {
ssrRender: (ctx: any, push: any, parent: any, attrs: any) => {
push(`<div${ssrRenderAttrs(attrs)}></div>`)
}
}
const Middle = {
render() {
return h(Child)
}
}
const Comp = {
__scopeId: 'parent',
ssrRender: (ctx: any, push: any, parent: any) => {
push(ssrRenderComponent(Middle, null, null, parent))
}
}
const result = await renderToString(createApp(Comp)) // output: `<div></div>`
expect(result).toBe(`<div parent></div>`)
})
})