MCPcopy Create free account
hub / github.com/adobe/react-spectrum / createFocusEvent

Function createFocusEvent

packages/react-aria/src/focus/virtualFocus.ts:38–48  ·  view source on GitHub ↗
(type: string, eventInitDict?: FocusEventInit)

Source from the content-addressed store, hash-verified

36
37let originalRelatedTargetMap: WeakMap<FocusEvent, EventTarget> | null = null;
38function createFocusEvent(type: string, eventInitDict?: FocusEventInit) {
39 const event = new FocusEvent(type, eventInitDict);
40 if (shadowDOM()) {
41 originalRelatedTargetMap ??= new WeakMap();
42 const relatedTarget = event.relatedTarget;
43 if (relatedTarget !== null) {
44 originalRelatedTargetMap.set(event, relatedTarget);
45 }
46 }
47 return event;
48}
49
50export function getOriginalRelatedTarget(event: FocusEvent): EventTarget | null {
51 if (!shadowDOM()) {

Callers 2

dispatchVirtualBlurFunction · 0.85
dispatchVirtualFocusFunction · 0.85

Calls 2

shadowDOMFunction · 0.90
setMethod · 0.45

Tested by

no test coverage detected