Skip to content

Commit

Permalink
refactor(core): Remove custom event and replay behavior.
Browse files Browse the repository at this point in the history
These behaviors have been moved back to g3.
  • Loading branch information
tbondwilkinson committed May 8, 2024
1 parent fb54863 commit 41bc51d
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 728 deletions.
2 changes: 0 additions & 2 deletions goldens/public-api/core/primitives/event-dispatch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export class EventContract implements UnrenamedEventContract {
addEvent(eventType: string, prefixedEventType?: string): void;
cleanUp(): void;
// (undocumented)
static CUSTOM_EVENT_SUPPORT: boolean;
// (undocumented)
ecaacs?: (updateEventInfoForA11yClick: typeof a11yClickLib.updateEventInfoForA11yClick, preventDefaultForA11yClick: typeof a11yClickLib.preventDefaultForA11yClick, populateClickOnlyAction: typeof a11yClickLib.populateClickOnlyAction) => void;
ecrd(dispatcher: Dispatcher_2, restriction: Restriction): void;
exportAddA11yClickSupport(): void;
Expand Down
17 changes: 0 additions & 17 deletions packages/core/primitives/event-dispatch/src/action_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const DEFAULT_EVENT_TYPE: string = EventType.CLICK;
/** Resolves actions for Events. */
export class ActionResolver {
private a11yClickSupport: boolean = false;
private readonly customEventSupport: boolean;
private readonly syntheticMouseEventSupport: boolean;

private updateEventInfoForA11yClick?: (eventInfo: eventInfoLib.EventInfo) => void = undefined;
Expand All @@ -46,30 +45,14 @@ export class ActionResolver {
) => void = undefined;

constructor({
customEventSupport = false,
syntheticMouseEventSupport = false,
}: {
customEventSupport?: boolean;
syntheticMouseEventSupport?: boolean;
} = {}) {
this.customEventSupport = customEventSupport;
this.syntheticMouseEventSupport = syntheticMouseEventSupport;
}

resolve(eventInfo: eventInfoLib.EventInfo) {
if (this.customEventSupport) {
if (eventInfoLib.getEventType(eventInfo) === EventType.CUSTOM) {
const detail = (eventInfoLib.getEvent(eventInfo) as CustomEvent).detail;
// For custom events, use a secondary dispatch based on the internal
// custom type of the event.
if (!detail || !detail['_type']) {
// This should never happen.
return;
}
eventInfoLib.setEventType(eventInfo, detail['_type']);
}
}

this.populateAction(eventInfo);
}

Expand Down
124 changes: 0 additions & 124 deletions packages/core/primitives/event-dispatch/src/custom_events.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,3 @@ export const A11Y_CLICK_SUPPORT = false;
* flag can be overridden in a build rule.
*/
export const MOUSE_SPECIAL_SUPPORT = false;

/**
* @define Support for custom events, which are type EventType.CUSTOM. These are
* native DOM events with an additional type field and an optional payload.
*/
export const CUSTOM_EVENT_SUPPORT = false;
11 changes: 1 addition & 10 deletions packages/core/primitives/event-dispatch/src/eventcontract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ import {ActionResolver} from './action_resolver';
import {EarlyJsactionData, EarlyJsactionDataContainer} from './earlyeventcontract';
import * as eventLib from './event';
import {EventContractContainerManager} from './event_contract_container';
import {
A11Y_CLICK_SUPPORT,
CUSTOM_EVENT_SUPPORT,
MOUSE_SPECIAL_SUPPORT,
} from './event_contract_defines';
import {A11Y_CLICK_SUPPORT, MOUSE_SPECIAL_SUPPORT} from './event_contract_defines';
import * as eventInfoLib from './event_info';
import {EventType} from './event_type';
import {Restriction} from './restriction';
Expand Down Expand Up @@ -87,14 +83,12 @@ type EventHandler = (eventType: string, event: Event, container: Element) => voi
* be delay loaded in a generic way.
*/
export class EventContract implements UnrenamedEventContract {
static CUSTOM_EVENT_SUPPORT = CUSTOM_EVENT_SUPPORT;
static A11Y_CLICK_SUPPORT = A11Y_CLICK_SUPPORT;
static MOUSE_SPECIAL_SUPPORT = MOUSE_SPECIAL_SUPPORT;

private containerManager: EventContractContainerManager | null;

private readonly actionResolver = new ActionResolver({
customEventSupport: EventContract.CUSTOM_EVENT_SUPPORT,
syntheticMouseEventSupport: EventContract.MOUSE_SPECIAL_SUPPORT,
});

Expand Down Expand Up @@ -135,9 +129,6 @@ export class EventContract implements UnrenamedEventContract {

constructor(containerManager: EventContractContainerManager) {
this.containerManager = containerManager;
if (EventContract.CUSTOM_EVENT_SUPPORT) {
this.addEvent(EventType.CUSTOM);
}
if (EventContract.A11Y_CLICK_SUPPORT) {
// Add a11y click support to the `EventContract`.
this.addA11yClickSupport();
Expand Down

0 comments on commit 41bc51d

Please sign in to comment.