@@ -454,7 +454,7 @@ describe('hydrate, shadow child', () => {
454454 ) ;
455455 }
456456 }
457- // @ts -ignore
457+
458458 const serverHydrated = await newSpecPage ( {
459459 components : [ CmpA , CmpB , CmpC ] ,
460460 html : `
@@ -467,6 +467,7 @@ describe('hydrate, shadow child', () => {
467467 ` ,
468468 hydrateServerSide : true ,
469469 } ) ;
470+
470471 expect ( serverHydrated . root ) . toEqualHtml ( `
471472 <cmp-a class="hydrated" s-id="1">
472473 <!--r.1-->
@@ -522,35 +523,78 @@ describe('hydrate, shadow child', () => {
522523 ` ) ;
523524 } ) ;
524525
525- it ( 'test shadow root innerHTML ' , async ( ) => {
526+ it ( 'preserves all nodes ' , async ( ) => {
526527 @Component ( {
527528 tag : 'cmp-a' ,
528529 shadow : true ,
529530 } )
530531 class CmpA {
531532 render ( ) {
532- return < div > Shadow Content</ div > ;
533+ return < slot > Shadow Content</ slot > ;
533534 }
534535 }
535536
536- const page = await newSpecPage ( {
537+ const serverHydrated = await newSpecPage ( {
537538 components : [ CmpA ] ,
538539 html : `
539540 <cmp-a>
540- Light Content
541+ A text node
542+ <!-- a comment -->
543+ <div>An element</div>
544+ <!-- another comment -->
545+ Another text node
541546 </cmp-a>
542547 ` ,
548+ hydrateServerSide : true ,
543549 } ) ;
544550
545- expect ( page . root ) . toEqualHtml ( `
546- <cmp-a>
551+ expect ( serverHydrated . root ) . toEqualHtml ( `
552+ <cmp-a class=\"hydrated\" s-id=\"1\">
553+ <!--r.1-->
554+ <!--o.0.1.-->
555+ <!--o.0.2.-->
556+ <!--o.0.4.-->
557+ <!--o.0.6.-->
558+ <!--o.0.7.-->
559+ <slot-fb c-id=\"1.0.0.0\" hidden=\"\" s-sn=\"\">
560+ <!--t.1.1.1.0-->
561+ Shadow Content
562+ </slot-fb>
563+ <!--t.0.1-->
564+ A text node
565+ <!--c.0.2-->
566+ <!-- a comment -->
567+ <div c-id=\"0.4\" s-sn=\"\">
568+ An element
569+ </div>
570+ <!--c.0.6-->
571+ <!-- another comment -->
572+ <!--t.0.7-->
573+ Another text node
574+ </cmp-a>
575+ ` ) ;
576+
577+ const clientHydrated = await newSpecPage ( {
578+ components : [ CmpA ] ,
579+ html : serverHydrated . root . outerHTML ,
580+ hydrateClientSide : true ,
581+ } ) ;
582+
583+ expect ( clientHydrated . root ) . toEqualHtml ( `
584+ <cmp-a class=\"hydrated\">
547585 <mock:shadow-root>
548- <div >
586+ <slot >
549587 Shadow Content
550- </div >
588+ </slot >
551589 </mock:shadow-root>
552- Light Content
553- </cmp-a>
590+ A text node
591+ <!-- a comment -->
592+ <div>
593+ An element
594+ </div>
595+ <!-- another comment -->
596+ Another text node
597+ </cmp-a>
554598 ` ) ;
555599 } ) ;
556600} ) ;
0 commit comments