Created
September 28, 2017 20:28
-
-
Save patbonecrusher/8e116d36ff359238fa728960d4e64361 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
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