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

Function constructSelectEvent

code/dependency-injection/public/app.js:6743–6768  ·  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

6741 * @return {?SyntheticEvent}
6742 */
6743function constructSelectEvent(nativeEvent, nativeEventTarget) {
6744 // Ensure we have the right element, and that the user is not dragging a
6745 // selection (this matches native `select` event behavior). In HTML5, select
6746 // fires only on input and textarea thus if there's no focused element we
6747 // won't dispatch.
6748 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement()) {
6749 return null;
6750 }
6751
6752 // Only fire when selection has actually changed.
6753 var currentSelection = getSelection(activeElement$1);
6754 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
6755 lastSelection = currentSelection;
6756
6757 var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
6758
6759 syntheticEvent.type = 'select';
6760 syntheticEvent.target = activeElement$1;
6761
6762 accumulateTwoPhaseDispatches(syntheticEvent);
6763
6764 return syntheticEvent;
6765 }
6766
6767 return null;
6768}
6769
6770/**
6771 * 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