Forked from patbonecrusher/mouseevent.path for safari and firefox.js
Created
October 17, 2018 05:13
-
-
Save WooodHead/4c75e7f2f0893f38d21b6ae65b49f405 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!('path' in Event.prototype)) { | |
Object.defineProperty(Event.prototype, 'path', { | |
get: function () { | |
const path = []; | |
let currentElem = this.target; | |
while (currentElem) { | |
path.push(currentElem); | |
currentElem = currentElem.parentElement; | |
} | |
if (path.indexOf(window) === -1 && path.indexOf(document) === -1) | |
path.push(document); | |
if (path.indexOf(window) === -1) | |
path.push(window); | |
return path; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment