Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save patbonecrusher/8e116d36ff359238fa728960d4e64361 to your computer and use it in GitHub Desktop.
Save patbonecrusher/8e116d36ff359238fa728960d4e64361 to your computer and use it in GitHub Desktop.
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