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

Function constructSelectEvent

code/redux/public/app.js:6901–6926  ·  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

6899 * @return {?SyntheticEvent}
6900 */
6901function constructSelectEvent(nativeEvent, nativeEventTarget) {
6902 // Ensure we have the right element, and that the user is not dragging a
6903 // selection (this matches native `select` event behavior). In HTML5, select
6904 // fires only on input and textarea thus if there's no focused element we
6905 // won't dispatch.
6906 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement()) {
6907 return null;
6908 }
6909
6910 // Only fire when selection has actually changed.
6911 var currentSelection = getSelection(activeElement$1);
6912 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
6913 lastSelection = currentSelection;
6914
6915 var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
6916
6917 syntheticEvent.type = 'select';
6918 syntheticEvent.target = activeElement$1;
6919
6920 accumulateTwoPhaseDispatches(syntheticEvent);
6921
6922 return syntheticEvent;
6923 }
6924
6925 return null;
6926}
6927
6928/**
6929 * 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