MCPcopy Create free account
hub / github.com/Lobos/react-ui / constructSelectEvent

Function constructSelectEvent

docs/lib/react.js:14286–14311  ·  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

14284 * @return {?SyntheticEvent}
14285 */
14286function constructSelectEvent(nativeEvent, nativeEventTarget) {
14287 // Ensure we have the right element, and that the user is not dragging a
14288 // selection (this matches native `select` event behavior). In HTML5, select
14289 // fires only on input and textarea thus if there's no focused element we
14290 // won't dispatch.
14291 if (mouseDown || activeElement == null || activeElement !== getActiveElement()) {
14292 return null;
14293 }
14294
14295 // Only fire when selection has actually changed.
14296 var currentSelection = getSelection(activeElement);
14297 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
14298 lastSelection = currentSelection;
14299
14300 var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select, activeElementInst, nativeEvent, nativeEventTarget);
14301
14302 syntheticEvent.type = 'select';
14303 syntheticEvent.target = activeElement;
14304
14305 EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
14306
14307 return syntheticEvent;
14308 }
14309
14310 return null;
14311}
14312
14313/**
14314 * This plugin creates an `onSelect` event that normalizes select events

Callers 1

react.jsFile · 0.85

Calls 3

getActiveElementFunction · 0.85
getSelectionFunction · 0.85
shallowEqualFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…