Created
February 22, 2017 15:25
-
-
Save hawkapparel/9f0060510ea616ad33a356a59f42d2de to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//It's not available, but if you really would like to have this property, | |
//then you could extend the native prototype of the Event object like so: | |
if (!("path" in Event.prototype)) | |
Object.defineProperty(Event.prototype, "path", { | |
get: function() { | |
var path = []; | |
var 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; | |
} | |
}); | |
Ref: http://stackoverflow.com/questions/36845515/mouseevent-path-equivalent-in-firefox-safari |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment