* Poll selection to see whether it's changed. * * @param {object} nativeEvent * @return {?SyntheticEvent}
(nativeEvent, nativeEventTarget)
| 14284 | * @return {?SyntheticEvent} |
| 14285 | */ |
| 14286 | function constructSelectEvent(nativeEvent, nativeEventTarget) { |
| 14287 | // Ensure we have the right element, and that the user is not dragging a |
| 14288 | // selection (this matches native `select` event behavior). In HTML5, select |
| 14289 | // fires only on input and textarea thus if there's no focused element we |
| 14290 | // won't dispatch. |
| 14291 | if (mouseDown || activeElement == null || activeElement !== getActiveElement()) { |
| 14292 | return null; |
| 14293 | } |
| 14294 | |
| 14295 | // Only fire when selection has actually changed. |
| 14296 | var currentSelection = getSelection(activeElement); |
| 14297 | if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { |
| 14298 | lastSelection = currentSelection; |
| 14299 | |
| 14300 | var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select, activeElementInst, nativeEvent, nativeEventTarget); |
| 14301 | |
| 14302 | syntheticEvent.type = 'select'; |
| 14303 | syntheticEvent.target = activeElement; |
| 14304 | |
| 14305 | EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent); |
| 14306 | |
| 14307 | return syntheticEvent; |
| 14308 | } |
| 14309 | |
| 14310 | return null; |
| 14311 | } |
| 14312 | |
| 14313 | /** |
| 14314 | * This plugin creates an `onSelect` event that normalizes select events |
no test coverage detected
searching dependent graphs…