* Poll selection to see whether it's changed. * * @param {object} nativeEvent * @param {object} nativeEventTarget * @return {?SyntheticEvent}
(nativeEvent, nativeEventTarget)
| 9771 | |
| 9772 | |
| 9773 | function constructSelectEvent(nativeEvent, nativeEventTarget) { |
| 9774 | // Ensure we have the right element, and that the user is not dragging a |
| 9775 | // selection (this matches native `select` event behavior). In HTML5, select |
| 9776 | // fires only on input and textarea thus if there's no focused element we |
| 9777 | // won't dispatch. |
| 9778 | var doc = getEventTargetDocument(nativeEventTarget); |
| 9779 | |
| 9780 | if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) { |
| 9781 | return null; |
| 9782 | } // Only fire when selection has actually changed. |
| 9783 | |
| 9784 | |
| 9785 | var currentSelection = getSelection$1(activeElement$1); |
| 9786 | |
| 9787 | if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { |
| 9788 | lastSelection = currentSelection; |
| 9789 | var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget); |
| 9790 | syntheticEvent.type = 'select'; |
| 9791 | syntheticEvent.target = activeElement$1; |
| 9792 | accumulateTwoPhaseDispatches(syntheticEvent); |
| 9793 | return syntheticEvent; |
| 9794 | } |
| 9795 | |
| 9796 | return null; |
| 9797 | } |
| 9798 | /** |
| 9799 | * This plugin creates an `onSelect` event that normalizes select events |
| 9800 | * across form elements. |
no test coverage detected