1 | /**
|
2 | * Copyright (c) 2013-present, Facebook, Inc.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | *
|
7 | */
|
8 |
|
9 | ;
|
10 |
|
11 | /**
|
12 | * Gets the target node from a native browser event by accounting for
|
13 | * inconsistencies in browser DOM APIs.
|
14 | *
|
15 | * @param {object} nativeEvent Native browser event.
|
16 | * @return {DOMEventTarget} Target node.
|
17 | */
|
18 |
|
19 | function getEventTarget(nativeEvent) {
|
20 | var target = nativeEvent.target || nativeEvent.srcElement || window;
|
21 |
|
22 | // Normalize SVG <use> element events #4963
|
23 | if (target.correspondingUseElement) {
|
24 | target = target.correspondingUseElement;
|
25 | }
|
26 |
|
27 | // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
|
28 | // @see http://www.quirksmode.org/js/events_properties.html
|
29 | return target.nodeType === 3 ? target.parentNode : target;
|
30 | }
|
31 |
|
32 | module.exports = getEventTarget; |
\ | No newline at end of file |