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

Function constructSelectEvent

code/third-party/public/app.js:5883–5908  ·  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

5881 * @return {?SyntheticEvent}
5882 */
5883function constructSelectEvent(nativeEvent, nativeEventTarget) {
5884 // Ensure we have the right element, and that the user is not dragging a
5885 // selection (this matches native `select` event behavior). In HTML5, select
5886 // fires only on input and textarea thus if there's no focused element we
5887 // won't dispatch.
5888 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement()) {
5889 return null;
5890 }
5891
5892 // Only fire when selection has actually changed.
5893 var currentSelection = getSelection(activeElement$1);
5894 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
5895 lastSelection = currentSelection;
5896
5897 var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
5898
5899 syntheticEvent.type = 'select';
5900 syntheticEvent.target = activeElement$1;
5901
5902 accumulateTwoPhaseDispatches(syntheticEvent);
5903
5904 return syntheticEvent;
5905 }
5906
5907 return null;
5908}
5909
5910/**
5911 * 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