File tree 2 files changed +31
-3
lines changed
2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 4
4
createCommentVNode ,
5
5
withScopeId ,
6
6
resolveComponent ,
7
- ComponentOptions
7
+ ComponentOptions ,
8
+ ref ,
9
+ defineComponent
8
10
} from 'vue'
9
11
import { escapeHtml , mockWarn } from '@vue/shared'
10
12
import { renderToString , renderComponent } from '../src/renderToString'
@@ -43,6 +45,32 @@ describe('ssr: renderToString', () => {
43
45
) . toBe ( `<div>hello</div>` )
44
46
} )
45
47
48
+ test ( 'option components returning render from setup' , async ( ) => {
49
+ expect (
50
+ await renderToString (
51
+ createApp ( {
52
+ setup ( ) {
53
+ const msg = ref ( 'hello' )
54
+ return ( ) => h ( 'div' , msg . value )
55
+ }
56
+ } )
57
+ )
58
+ ) . toBe ( `<div>hello</div>` )
59
+ } )
60
+
61
+ test ( 'setup components returning render from setup' , async ( ) => {
62
+ expect (
63
+ await renderToString (
64
+ createApp (
65
+ defineComponent ( ( props : { } ) => {
66
+ const msg = ref ( 'hello' )
67
+ return ( ) => h ( 'div' , msg . value )
68
+ } )
69
+ )
70
+ )
71
+ ) . toBe ( `<div>hello</div>` )
72
+ } )
73
+
46
74
test ( 'optimized components' , async ( ) => {
47
75
expect (
48
76
await renderToString (
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ function renderComponentSubTree(
177
177
if ( isFunction ( comp ) ) {
178
178
renderVNode ( push , renderComponentRoot ( instance ) , instance )
179
179
} else {
180
- if ( ! comp . ssrRender && ! comp . render && isString ( comp . template ) ) {
180
+ if ( ! instance . render && ! comp . ssrRender && isString ( comp . template ) ) {
181
181
comp . ssrRender = ssrCompile ( comp . template , instance )
182
182
}
183
183
@@ -187,7 +187,7 @@ function renderComponentSubTree(
187
187
setCurrentRenderingInstance ( instance )
188
188
comp . ssrRender ( instance . proxy , push , instance )
189
189
setCurrentRenderingInstance ( null )
190
- } else if ( comp . render ) {
190
+ } else if ( instance . render ) {
191
191
renderVNode ( push , renderComponentRoot ( instance ) , instance )
192
192
} else {
193
193
throw new Error (
You can’t perform that action at this time.
0 commit comments