File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export function renderToString(template) {
14
14
}
15
15
16
16
const renderResult = template . _h ( )
17
+
17
18
let htmlString = renderResult [ 0 ]
18
19
const expressions = renderResult [ 1 ]
19
20
if ( expressions . length > 0 ) {
@@ -36,7 +37,10 @@ export function renderToString(template) {
36
37
37
38
const watcherReturn = expressionInstance . e ( )
38
39
39
- if ( typeof watcherReturn === 'string' ) {
40
+ if (
41
+ typeof watcherReturn !== 'object' &&
42
+ typeof watcherReturn !== 'function'
43
+ ) {
40
44
htmlString = htmlString . replace ( delimiterComment , watcherReturn )
41
45
return
42
46
}
Original file line number Diff line number Diff line change @@ -30,6 +30,26 @@ test('reactive variable', async () => {
30
30
assert . is ( out , '<p>hello world</p>' )
31
31
} )
32
32
33
+ test ( 'reactive variable nested' , async ( ) => {
34
+ const pageState = reactive ( {
35
+ count : 0 ,
36
+ } )
37
+ const comp = html `< div
38
+ class ="flex-[5] relative p-2 overflow-x-auto flex flex-col gap-2 "
39
+ >
40
+ < div class ="flex gap-2 items-center "> ${ ( ) => pageState . count } </ div >
41
+ </ div > `
42
+
43
+ await inlineSnapshot (
44
+ renderToString ( comp ) ,
45
+ `<div
46
+ class="flex-[5] relative p-2 overflow-x-auto flex flex-col gap-2"
47
+ >
48
+ <div class="flex gap-2 items-center">0</div>
49
+ </div>`
50
+ )
51
+ } )
52
+
33
53
test ( 'reactive variable, changing' , async ( ) => {
34
54
const rVar = reactive ( { message : 'hello world' } )
35
55
const tmp = html `< p > ${ ( ) => rVar . message } </ p > `
You can’t perform that action at this time.
0 commit comments