MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / constructSelectEvent

Function constructSelectEvent

code/composition/public/app.js:6788–6813  ·  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

6786 * @return {?SyntheticEvent}
6787 */
6788function constructSelectEvent(nativeEvent, nativeEventTarget) {
6789 // Ensure we have the right element, and that the user is not dragging a
6790 // selection (this matches native `select` event behavior). In HTML5, select
6791 // fires only on input and textarea thus if there's no focused element we
6792 // won't dispatch.
6793 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement()) {
6794 return null;
6795 }
6796
6797 // Only fire when selection has actually changed.
6798 var currentSelection = getSelection(activeElement$1);
6799 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
6800 lastSelection = currentSelection;
6801
6802 var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
6803
6804 syntheticEvent.type = 'select';
6805 syntheticEvent.target = activeElement$1;
6806
6807 accumulateTwoPhaseDispatches(syntheticEvent);
6808
6809 return syntheticEvent;
6810 }
6811
6812 return null;
6813}
6814
6815/**
6816 * 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