@@ -88,12 +88,12 @@ function prepareForHydration(platformState: PlatformState, applicationRef: Appli
8888
8989 appendSsrContentIntegrityMarker ( doc ) ;
9090
91- const eventTypesToBeReplayed = annotateForHydration ( applicationRef , doc ) ;
92- if ( eventTypesToBeReplayed ) {
91+ const eventTypesToReplay = annotateForHydration ( applicationRef , doc ) ;
92+ if ( eventTypesToReplay . regular . size || eventTypesToReplay . capture . size ) {
9393 insertEventRecordScript (
9494 environmentInjector . get ( APP_ID ) ,
9595 doc ,
96- eventTypesToBeReplayed ,
96+ eventTypesToReplay ,
9797 environmentInjector . get ( CSP_NONCE , null ) ,
9898 ) ;
9999 } else {
@@ -136,31 +136,16 @@ function appendServerContextInfo(applicationRef: ApplicationRef) {
136136function insertEventRecordScript (
137137 appId : string ,
138138 doc : Document ,
139- eventTypesToBeReplayed : Set < string > ,
139+ eventTypesToReplay : { regular : Set < string > ; capture : Set < string > } ,
140140 nonce : string | null ,
141141) : void {
142+ const { regular, capture} = eventTypesToReplay ;
142143 const eventDispatchScript = findEventDispatchScript ( doc ) ;
143144 if ( eventDispatchScript ) {
144- const events = Array . from ( eventTypesToBeReplayed ) ;
145- const captureEventTypes = [ ] ;
146- const eventTypes = [ ] ;
147- for ( const eventType of events ) {
148- if (
149- eventType === 'focus' ||
150- eventType === 'blur' ||
151- eventType === 'error' ||
152- eventType === 'load' ||
153- eventType === 'toggle'
154- ) {
155- captureEventTypes . push ( eventType ) ;
156- } else {
157- eventTypes . push ( eventType ) ;
158- }
159- }
160145 // This is defined in packages/core/primitives/event-dispatch/contract_binary.ts
161146 const replayScriptContents = `window.__jsaction_bootstrap('ngContracts', document.body, ${ JSON . stringify (
162147 appId ,
163- ) } , ${ JSON . stringify ( eventTypes ) } ${ captureEventTypes . length ? ',' + JSON . stringify ( captureEventTypes ) : '' } );`;
148+ ) } , ${ JSON . stringify ( Array . from ( regular ) ) } ${ capture . size ? ',' + JSON . stringify ( Array . from ( capture ) ) : '' } );`;
164149
165150 const replayScript = createScript ( doc , replayScriptContents , nonce ) ;
166151
0 commit comments