feat(ssr): support custom directive getSSRProps in optimized compilation
close #5304
This commit is contained in:
@@ -10,8 +10,10 @@ import {
|
||||
vShow,
|
||||
vModelText,
|
||||
vModelRadio,
|
||||
vModelCheckbox
|
||||
vModelCheckbox,
|
||||
resolveDirective
|
||||
} from 'vue'
|
||||
import { ssrGetDirectiveProps, ssrRenderAttrs } from '../src'
|
||||
|
||||
describe('ssr: directives', () => {
|
||||
describe('template v-show', () => {
|
||||
@@ -374,7 +376,7 @@ describe('ssr: directives', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('custom directive w/ getSSRProps', async () => {
|
||||
test('custom directive w/ getSSRProps (vdom)', async () => {
|
||||
expect(
|
||||
await renderToString(
|
||||
createApp({
|
||||
@@ -394,4 +396,35 @@ describe('ssr: directives', () => {
|
||||
)
|
||||
).toBe(`<div id="foo"></div>`)
|
||||
})
|
||||
|
||||
test('custom directive w/ getSSRProps (optimized)', async () => {
|
||||
expect(
|
||||
await renderToString(
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
x: 'foo'
|
||||
}
|
||||
},
|
||||
directives: {
|
||||
xxx: {
|
||||
getSSRProps({ value, arg, modifiers }) {
|
||||
return { id: [value, arg, modifiers.ok].join('-') }
|
||||
}
|
||||
}
|
||||
},
|
||||
ssrRender(_ctx, _push, _parent, _attrs) {
|
||||
const _directive_xxx = resolveDirective('xxx')!
|
||||
_push(
|
||||
`<div${ssrRenderAttrs(
|
||||
ssrGetDirectiveProps(_ctx, _directive_xxx, _ctx.x, 'arg', {
|
||||
ok: true
|
||||
})
|
||||
)}></div>`
|
||||
)
|
||||
}
|
||||
})
|
||||
)
|
||||
).toBe(`<div id="foo-arg-true"></div>`)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user