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

Function constructSelectEvent

code/communication/public/app.js:6685–6710  ·  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

6683 * @return {?SyntheticEvent}
6684 */
6685function constructSelectEvent(nativeEvent, nativeEventTarget) {
6686 // Ensure we have the right element, and that the user is not dragging a
6687 // selection (this matches native `select` event behavior). In HTML5, select
6688 // fires only on input and textarea thus if there's no focused element we
6689 // won't dispatch.
6690 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement()) {
6691 return null;
6692 }
6693
6694 // Only fire when selection has actually changed.
6695 var currentSelection = getSelection(activeElement$1);
6696 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
6697 lastSelection = currentSelection;
6698
6699 var syntheticEvent = SyntheticEvent$1.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
6700
6701 syntheticEvent.type = 'select';
6702 syntheticEvent.target = activeElement$1;
6703
6704 accumulateTwoPhaseDispatches(syntheticEvent);
6705
6706 return syntheticEvent;
6707 }
6708
6709 return null;
6710}
6711
6712/**
6713 * 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