apply test_install into method
[osm/UI.git] / skyquake / plugins / composer / src / src / libraries / getEventPath.js
1 /**
2 * Created by onvelocity on 2/3/16.
3 */
4 'use strict';
5 export default function getEventPath(event) {
6 if (event.path) {
7 return event.path;
8 }
9 if (event.nativeEvent && event.nativeEvent.path) {
10 return event.nativeEvent.path;
11 }
12 // for browsers, like IE, that don't have event.path
13 let node = event.target;
14 const path = [];
15 // Array.unshift means put the value on the top of the array
16 const addToPath = (value) => path.unshift(value);
17 // warn: some browsers set the root's parent to itself
18 while (node && node !== node.parentNode) {
19 addToPath(node);
20 node = node.parentNode;
21 }
22 return path;
23 }