MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / constructSelectEvent

Function constructSelectEvent

code/event-handlers/public/app.js:5980–6005  ·  view source on GitHub ↗

* Poll selection to see whether it's changed. * * @param {object} nativeEvent * @return {?SyntheticEvent}

(nativeEvent, nativeEventTarget)

Source from the content-addressed store, hash-verified

5978 * @return {?SyntheticEvent}
5979 */
5980function constructSelectEvent(nativeEvent, nativeEventTarget) {
5981 // Ensure we have the right element, and that the user is not dragging a
5982 // selection (this matches native `select` event behavior). In HTML5, select
5983 // fires only on input and textarea thus if there's no focused element we
5984 // won't dispatch.
5985 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement()) {
5986 return null;
5987 }
5988
5989 // Only fire when selection has actually changed.
5990 var currentSelection = getSelection(activeElement$1);
5991 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
5992 lastSelection = currentSelection;
5993
5994 var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
5995
5996 syntheticEvent.type = 'select';
5997 syntheticEvent.target = activeElement$1;
5998
5999 accumulateTwoPhaseDispatches(syntheticEvent);
6000
6001 return syntheticEvent;
6002 }
6003
6004 return null;
6005}
6006
6007/**
6008 * This plugin creates an `onSelect` event that normalizes select events

Callers 1

app.jsFile · 0.70

Calls 4

getActiveElementFunction · 0.70
getSelectionFunction · 0.70
shallowEqualFunction · 0.70

Tested by

no test coverage detected