2
2
effectScope ,
3
3
insert ,
4
4
isFragment ,
5
+ isVaporComponent ,
5
6
remove ,
6
7
renderEffect ,
7
8
VaporFragment ,
@@ -12,27 +13,29 @@ import {
12
13
export { shallowRef as useRef } from 'vue'
13
14
14
15
function createFragment (
15
- nodes : Block [ ] ,
16
+ nodes : Block ,
16
17
anchor : Node | undefined = document . createTextNode ( '' ) ,
17
18
) {
18
19
const frag = new VaporFragment ( nodes )
19
20
frag . anchor = anchor
20
21
return frag
21
22
}
22
23
23
- function normalizeValue ( value : any , anchor ?: Element ) : Block {
24
- if ( value instanceof Node || isFragment ( value ) ) {
24
+ function normalizeNode ( node : any , anchor ?: Element ) : Block {
25
+ if ( node instanceof Node || isFragment ( node ) ) {
25
26
anchor && ( anchor . textContent = '' )
26
- return value
27
- } else if ( Array . isArray ( value ) ) {
27
+ return node
28
+ } else if ( isVaporComponent ( node ) ) {
29
+ anchor && ( anchor . textContent = '' )
30
+ return createFragment ( node , anchor )
31
+ } else if ( Array . isArray ( node ) ) {
28
32
anchor && ( anchor . textContent = '' )
29
33
return createFragment (
30
- value . map ( ( i ) => normalizeValue ( i ) ) ,
34
+ node . map ( ( i ) => normalizeNode ( i ) ) ,
31
35
anchor ,
32
36
)
33
37
} else {
34
- const result =
35
- value == null || typeof value === 'boolean' ? '' : String ( value )
38
+ const result = node == null || typeof node === 'boolean' ? '' : String ( node )
36
39
if ( anchor ) {
37
40
anchor . textContent = result
38
41
return anchor
@@ -43,7 +46,7 @@ function normalizeValue(value: any, anchor?: Element): Block {
43
46
}
44
47
45
48
function resolveValue ( current : Block , value : any , anchor ?: Element ) {
46
- const node = normalizeValue ( value , anchor )
49
+ const node = normalizeNode ( value , anchor )
47
50
if ( current ) {
48
51
if ( isFragment ( current ) ) {
49
52
const { anchor } = current
0 commit comments