@@ -222,7 +222,7 @@ describe('platform-server partial hydration integration', () => {
222222 const ssrContents = getAppContents ( html ) ;
223223
224224 expect ( ssrContents ) . toContain (
225- '"__nghDeferData__":{"d0":{"p":null," r":1,"s":2},"d1":{"p":"d0","r ":2,"s":2 }}' ,
225+ '"__nghDeferData__":{"d0":{"r":1,"s":2},"d1":{"r":2,"s ":2,"p":"d0" }}' ,
226226 ) ;
227227 } ) ;
228228
@@ -285,9 +285,38 @@ describe('platform-server partial hydration integration', () => {
285285 const ssrContents = getAppContents ( html ) ;
286286
287287 expect ( ssrContents ) . toContain (
288- '"__nghDeferData__":{"d0":{"p":null," r":1,"s":2},"d1":{"p":"d0"," r":2,"s":2,"t":[2]}}' ,
288+ '"__nghDeferData__":{"d0":{"r":1,"s":2},"d1":{"r":2,"s":2,"t":[2],"p":"d0" }}' ,
289289 ) ;
290290 } ) ;
291+
292+ it ( 'should not include parent id in serialized data for top-level `@defer` blocks' , async ( ) => {
293+ @Component ( {
294+ selector : 'app' ,
295+ template : `
296+ @defer (on viewport; hydrate on interaction) {
297+ Hello world!
298+ } @placeholder {
299+ <span>Placeholder</span>
300+ }
301+ ` ,
302+ } )
303+ class SimpleComponent { }
304+
305+ const appId = 'custom-app-id' ;
306+ const providers = [ { provide : APP_ID , useValue : appId } ] ;
307+ const hydrationFeatures = ( ) => [ withIncrementalHydration ( ) ] ;
308+
309+ const html = await ssr ( SimpleComponent , {
310+ envProviders : providers ,
311+ hydrationFeatures,
312+ } ) ;
313+
314+ const ssrContents = getAppContents ( html ) ;
315+
316+ // Assert that the serialized data doesn't contain the "p" field,
317+ // which contains parent id (which is not needed for top-level blocks).
318+ expect ( ssrContents ) . toContain ( '"__nghDeferData__":{"d0":{"r":1,"s":2}}}' ) ;
319+ } ) ;
291320 } ) ;
292321
293322 describe ( 'basic hydration behavior' , ( ) => {
@@ -347,7 +376,7 @@ describe('platform-server partial hydration integration', () => {
347376 expect ( ssrContents ) . toContain ( '<p jsaction="click:;keydown:;" ngb="d1' ) ;
348377 // There is an extra annotation in the TransferState data.
349378 expect ( ssrContents ) . toContain (
350- '"__nghDeferData__":{"d0":{"p":null," r":1,"s":2},"d1":{"p":"d0"," r":1,"s":2}}' ,
379+ '"__nghDeferData__":{"d0":{"r":1,"s":2},"d1":{"r":1,"s":2,"p":"d0" }}' ,
351380 ) ;
352381 // Outer defer block is rendered.
353382 expect ( ssrContents ) . toContain ( 'Main defer block rendered' ) ;
@@ -460,7 +489,7 @@ describe('platform-server partial hydration integration', () => {
460489 expect ( ssrContents ) . toContain ( '<p jsaction="click:;keydown:;" ngb="d1' ) ;
461490 // There is an extra annotation in the TransferState data.
462491 expect ( ssrContents ) . toContain (
463- '"__nghDeferData__":{"d0":{"p":null," r":1,"s":2},"d1":{"p":"d0"," r":1,"s":2}}' ,
492+ '"__nghDeferData__":{"d0":{"r":1,"s":2},"d1":{"r":1,"s":2,"p":"d0" }}' ,
464493 ) ;
465494 // Outer defer block is rendered.
466495 expect ( ssrContents ) . toContain ( 'Main defer block rendered' ) ;
@@ -569,7 +598,7 @@ describe('platform-server partial hydration integration', () => {
569598 // <p> is inside a nested defer block -> different namespace.
570599 // expect(ssrContents).toContain('<p jsaction="click:;" ngb="d1');
571600 // There is an extra annotation in the TransferState data.
572- expect ( ssrContents ) . toContain ( '"__nghDeferData__":{"d0":{"p":null," r":1,"s":2}}' ) ;
601+ expect ( ssrContents ) . toContain ( '"__nghDeferData__":{"d0":{"r":1,"s":2}}' ) ;
573602 // Outer defer block is rendered.
574603 expect ( ssrContents ) . toContain ( 'Main defer block rendered' ) ;
575604 // Inner defer block should only display placeholder.
0 commit comments