1/** 2 * Copyright 2013-2014, Facebook, Inc. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. An additional grant 7 * of patent rights can be found in the PATENTS file in the same directory. 8 * 9 * @providesModule getEventTarget 10 * @typechecks static-only 11 */ 12 13"use strict"; 14 15/** 16 * Gets the target node from a native browser event by accounting for 17 * inconsistencies in browser DOM APIs. 18 * 19 * @param {object} nativeEvent Native browser event. 20 * @return {DOMEventTarget} Target node. 21 */ 22function getEventTarget(nativeEvent) { 23 var target = nativeEvent.target || nativeEvent.srcElement || window; 24 // Safari may fire events on text nodes (Node.TEXT_NODE is 3). 25 // @see http://www.quirksmode.org/js/events_properties.html 26 return target.nodeType === 3 ? target.parentNode : target; 27} 28 29module.exports = getEventTarget; 30 31