This repository was archived by the owner on Jul 19, 2025. It is now read-only.
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', () => {
11601160 expect ( ( vnode as any ) . component ?. subTree . children [ 0 ] . el ) . toBe ( text )
11611161 } )
11621162
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+
11631178 test ( 'app.unmount()' , async ( ) => {
11641179 const container = document . createElement ( 'DIV' )
11651180 container . innerHTML = '<button></button>'
Original file line number Diff line number Diff line change @@ -541,7 +541,9 @@ export function createHydrationFunctions(
541541 optimized ,
542542 )
543543 } 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 )
545547 } else {
546548 hasMismatch = true
547549 if (
You can’t perform that action at this time.
0 commit comments