Last active
August 27, 2017 00:21
-
-
Save jimmont/761369d2f2d3f275e2dd1c70dd4fa563 to your computer and use it in GitHub Desktop.
collection to sync various api details in Safari-current and Chrome-current
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(!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