File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -11,27 +11,40 @@ export function normalizeChildren (children: any): Array<VNode> {
11
11
children = children ( )
12
12
}
13
13
if ( isPrimitive ( children ) ) {
14
- return [ new VNode ( undefined , undefined , undefined , String ( children ) ) ]
14
+ return [ createTextVNode ( children ) ]
15
15
}
16
16
if ( Array . isArray ( children ) ) {
17
17
const res = [ ]
18
18
for ( let i = 0 , l = children . length ; i < l ; i ++ ) {
19
19
const c = children [ i ]
20
+ const last = res [ res . length - 1 ]
20
21
// nested
21
22
if ( Array . isArray ( c ) ) {
22
23
res . push . apply ( res , normalizeChildren ( c ) )
23
24
} else if ( isPrimitive ( c ) ) {
24
- // convert primitive to vnode
25
- res . push ( new VNode ( undefined , undefined , undefined , String ( c ) ) )
25
+ if ( last && last . text ) {
26
+ last . text += String ( c )
27
+ } else {
28
+ // convert primitive to vnode
29
+ res . push ( createTextVNode ( c ) )
30
+ }
26
31
} else if ( c instanceof VNode ) {
27
- res . push ( c )
32
+ if ( c . text && last && last . text ) {
33
+ last . text += c . text
34
+ } else {
35
+ res . push ( c )
36
+ }
28
37
}
29
38
}
30
39
return res
31
40
}
32
41
return [ ]
33
42
}
34
43
44
+ function createTextVNode ( val ) {
45
+ return new VNode ( undefined , undefined , undefined , String ( val ) )
46
+ }
47
+
35
48
export function updateListeners (
36
49
on : Object ,
37
50
oldOn : Object ,
You can’t perform that action at this time.
0 commit comments