One add / remove interface for event listeners that behaves the same on
modern browsers, legacy IE (attachEvent), Cordova and iOS WebKit — vendor-prefix
resolution, once / passive / signal emulation, and
pointer→touch synthesis. Everything below runs live in this page.
What this engine accepts natively. once and signal are emulated by the
kit either way, so the registry stays consistent and removal behaves identically everywhere.
readonly version: string;
readonly utils: EventKitUtils;
get supportedOptions(): SupportedListenerOptions;
interface SupportedListenerOptions {
once: boolean;
passive: boolean;
capture: boolean;
some: boolean;
all: boolean;
}
The type this engine actually fires for what you asked for. Resolution walks Cordova lifecycle
events, iOS <video> fullscreen events, alias chains, then vendor prefixes, and
passes unknown types straight through — it never throws.
resolveType(target: EventTarget, type: string): string;
Try wheel · touchstart · fullscreenchange · transitionend · webkitbeginfullscreen · deviceready · demo:ping
add hands back a release function, so cleanup never needs the callback again;
remove is there for the symmetric form. Registering the same target, type, callback
and capture twice is ignored the way the spec ignores it, and the second
add returns a release function that does nothing.
add(target: EventTarget, type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): ReleaseEventListener;
remove(target: EventTarget, type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
type ReleaseEventListener = () => void;
release() and abort() act on the most recent registration. Ask
for touchstart on a pointer-only engine and the callback still sees
event.type === 'touchstart' with a synthesized TouchList.
Constructor-free event factories that fall back to document.createEvent and
initCustomEvent on IE 9–11. Add a listener for the type above first and the
dispatch shows up in its log.
createEvent(type: string, init?: EventInit): Event;
createCustomEvent<T>(type: string, init?: CustomEventInit<T>): CustomEvent<T>;