File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1160,6 +1160,21 @@ describe('SSR hydration', () => {
1160
1160
expect ( ( vnode as any ) . component ?. subTree . children [ 0 ] . el ) . toBe ( text )
1161
1161
} )
1162
1162
1163
+ // #7215
1164
+ test ( 'empty text node' , ( ) => {
1165
+ const Comp = {
1166
+ render ( this : any ) {
1167
+ return h ( 'p' , [ '' ] )
1168
+ }
1169
+ }
1170
+ const { container } = mountWithHydration ( '<p></p>' , ( ) => h ( Comp ) )
1171
+ expect ( container . childNodes . length ) . toBe ( 1 )
1172
+ const p = container . childNodes [ 0 ]
1173
+ expect ( p . childNodes . length ) . toBe ( 1 )
1174
+ const text = p . childNodes [ 0 ]
1175
+ expect ( text . nodeType ) . toBe ( 3 )
1176
+ } )
1177
+
1163
1178
test ( 'app.unmount()' , async ( ) => {
1164
1179
const container = document . createElement ( 'DIV' )
1165
1180
container . innerHTML = '<button></button>'
Original file line number Diff line number Diff line change @@ -541,7 +541,9 @@ export function createHydrationFunctions(
541
541
optimized ,
542
542
)
543
543
} else if ( vnode . type === Text && ! vnode . children ) {
544
- continue
544
+ // #7215 create a TextNode for empty text node
545
+ // because server rendered HTML won't contain a text node
546
+ insert ( ( vnode . el = createText ( '' ) ) , container )
545
547
} else {
546
548
hasMismatch = true
547
549
if (
You can’t perform that action at this time.
0 commit comments