@@ -19,6 +19,7 @@ import {
1919 ɵIS_HYDRATION_DOM_REUSE_ENABLED  as  IS_HYDRATION_DOM_REUSE_ENABLED , 
2020 ɵSSR_CONTENT_INTEGRITY_MARKER  as  SSR_CONTENT_INTEGRITY_MARKER , 
2121 ɵwhenStable  as  whenStable , 
22+  CSP_NONCE , 
2223}  from  '@angular/core' ; 
2324
2425import  { PlatformState }  from  './platform_state' ; 
@@ -96,13 +97,14 @@ function insertEventRecordScript(
9697 appId : string , 
9798 doc : Document , 
9899 eventTypesToBeReplayed : Set < string > , 
99- )  { 
100+  nonce : string  |  null , 
101+ ) : void { 
100102 const  events  =  Array . from ( eventTypesToBeReplayed ) ; 
101103 // This is defined in packages/core/primitives/event-dispatch/contract_binary.ts 
102104 const  replayScript  =  `window.__jsaction_bootstrap('ngContracts', document.body, ${ JSON . stringify (  
103105 appId ,  
104106 ) }  , ${ JSON . stringify ( events ) } ; 
105-  const  script  =  createScript ( doc ,  replayScript ) ; 
107+  const  script  =  createScript ( doc ,  replayScript ,   nonce ) ; 
106108 doc . body . insertBefore ( script ,  doc . body . firstChild ) ; 
107109} 
108110
@@ -113,12 +115,17 @@ async function _render(platformRef: PlatformRef, applicationRef: ApplicationRef)
113115 await  whenStable ( applicationRef ) ; 
114116
115117 const  platformState  =  platformRef . injector . get ( PlatformState ) ; 
116-  if  ( applicationRef . injector . get ( IS_HYDRATION_DOM_REUSE_ENABLED ,  false ) )  { 
118+  if  ( environmentInjector . get ( IS_HYDRATION_DOM_REUSE_ENABLED ,  false ) )  { 
117119 const  doc  =  platformState . getDocument ( ) ; 
118120 appendSsrContentIntegrityMarker ( doc ) ; 
119121 const  eventTypesToBeReplayed  =  annotateForHydration ( applicationRef ,  doc ) ; 
120122 if  ( eventTypesToBeReplayed )  { 
121-  insertEventRecordScript ( environmentInjector . get ( APP_ID ) ,  doc ,  eventTypesToBeReplayed ) ; 
123+  insertEventRecordScript ( 
124+  environmentInjector . get ( APP_ID ) , 
125+  doc , 
126+  eventTypesToBeReplayed , 
127+  environmentInjector . get ( CSP_NONCE ,  null ) , 
128+  ) ; 
122129 }  else  { 
123130 // No events to replay, we should remove inlined event dispatch script 
124131 // (which was injected by the build process) from the HTML. 
0 commit comments