MCPcopy Create free account
hub / github.com/reactjs/react-rails / constructSelectEvent

Function constructSelectEvent

lib/assets/react-source/development/react.js:13345–13369  ·  view source on GitHub ↗

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

(nativeEvent, nativeEventTarget)

Source from the content-addressed store, hash-verified

13343
13344
13345 function constructSelectEvent(nativeEvent, nativeEventTarget) {
13346 // Ensure we have the right element, and that the user is not dragging a
13347 // selection (this matches native `select` event behavior). In HTML5, select
13348 // fires only on input and textarea thus if there's no focused element we
13349 // won't dispatch.
13350 var doc = getEventTargetDocument(nativeEventTarget);
13351
13352 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
13353 return null;
13354 } // Only fire when selection has actually changed.
13355
13356
13357 var currentSelection = getSelection$1(activeElement$1);
13358
13359 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
13360 lastSelection = currentSelection;
13361 var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
13362 syntheticEvent.type = 'select';
13363 syntheticEvent.target = activeElement$1;
13364 accumulateTwoPhaseDispatches(syntheticEvent);
13365 return syntheticEvent;
13366 }
13367
13368 return null;
13369 }
13370 /**
13371 * This plugin creates an `onSelect` event that normalizes select events
13372 * across form elements.

Callers 1

react.jsFile · 0.85

Calls 5

getEventTargetDocumentFunction · 0.85
getActiveElementFunction · 0.85
getSelection$1Function · 0.85
shallowEqualFunction · 0.85

Tested by

no test coverage detected