Skip to content

Instantly share code, notes, and snippets.

@jimmont jimmont/normal.js
Last active Aug 27, 2017

Embed
What would you like to do?
collection to sync various api details in Safari-current and Chrome-current
if(!Event.prototype.hasOwnProperty('path')){
/*
in event handlers use the event.path which looks like:
for attached DOM nodes [target,target.parentNode,...<ancestors>...,document,window]
for unattached DOM nodes [target]
for window and document: [window] [document, window]
*/
Object.defineProperty(Event.prototype, 'path', {
// for Safari
get:function(){
var value = [], $0 = this.target, $1;
while($0){
value.push($0);
$0 = $0.parentNode;
};
$0 = value[value.length - 1];
// if last item is a document, include its window
if($0){
$0 = $0.defaultView;
if($0) value.push($0);
};
return value;
}
,set: function(){ }
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.