MCPcopy Create free account
hub / github.com/reactjs/react-rails / getEventTarget

Function getEventTarget

lib/assets/react-source/development/react.js:7019–7031  ·  view source on GitHub ↗

* Gets the target node from a native browser event by accounting for * inconsistencies in browser DOM APIs. * * @param {object} nativeEvent Native browser event. * @return {DOMEventTarget} Target node.

(nativeEvent)

Source from the content-addressed store, hash-verified

7017 */
7018
7019 function getEventTarget(nativeEvent) {
7020 // Fallback to nativeEvent.srcElement for IE9
7021 // https://github.com/facebook/react/issues/12506
7022 var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963
7023
7024 if (target.correspondingUseElement) {
7025 target = target.correspondingUseElement;
7026 } // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
7027 // @see http://www.quirksmode.org/js/events_properties.html
7028
7029
7030 return target.nodeType === TEXT_NODE ? target.parentNode : target;
7031 }
7032
7033 /**
7034 * Checks if an event is supported in the current execution environment.

Callers 3

handleTopLevelFunction · 0.85
attemptToDispatchEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected