Skip to content

Commit

Permalink
refactor(core): Export some more symbols and check for truthiness on …
Browse files Browse the repository at this point in the history
…event types before adding them. (#55587)

In some cases, we will be passing in undefined for capture events, so handle this.

PR Close #55587
  • Loading branch information
iteriani authored and atscott committed May 9, 2024
1 parent 61007dc commit d00f9e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions goldens/public-api/core/primitives/event-dispatch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export class Dispatcher {
unregisterHandler(namespace: string, name: string): void;
}

// @public (undocumented)
export interface EarlyJsactionDataContainer {
// (undocumented)
_ejsa?: EarlyJsactionData;
}

// @public
export class EventContract implements UnrenamedEventContract {
constructor(containerManager: EventContractContainerManager);
Expand Down
1 change: 1 addition & 0 deletions packages/core/primitives/event-dispatch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

export {Dispatcher, registerDispatcher} from './src/dispatcher';
export {EventContractContainer} from './src/event_contract_container';
export type {EarlyJsactionDataContainer} from './src/earlyeventcontract';
export {EventContract} from './src/eventcontract';
export {bootstrapEventContract, bootstrapEarlyEventContract} from './src/register_events';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export function bootstrapEarlyEventContract(
field: string,
container: HTMLElement,
appId: string,
eventTypes: string[],
captureEventTypes: string[],
eventTypes?: string[],
captureEventTypes?: string[],
earlyJsactionTracker: EventContractTracker<EarlyJsactionDataContainer> = window as unknown as EventContractTracker<EarlyJsactionDataContainer>,
) {
if (!earlyJsactionTracker[field]) {
earlyJsactionTracker[field] = {};
}
earlyJsactionTracker[field][appId] = {};
const eventContract = new EarlyEventContract(earlyJsactionTracker[field][appId], container);
eventContract.addEvents(eventTypes);
eventContract.addEvents(captureEventTypes, true);
eventTypes && eventContract.addEvents(eventTypes);
captureEventTypes && eventContract.addEvents(captureEventTypes, true);
}

0 comments on commit d00f9e8

Please sign in to comment.