I started to extend the EventTarget
interface by adding some useful prototypes
but then I tested it on Safari 8 and get :
[Error] ReferenceError: Can't find variable: EventTarget
I found on MDN that "window.EventTarget
does not exist" for Safari.
This question looks really interesting but it's about IE8.
So, I want to know if a reference to the EventTarget interface is accessible on Safari, or a workaround to use code like EventTarget.prototype.hasEventListener
and EventTarget.prototype.hasEventListener
without getting any errors on Safari ?
Edit I found an interesting commit which says that it was implemented the 09/12/15 (from timestamp), but it sure doesn't work in Safari 9.1
Workaround :
I simply used the
Element
interface as a fallback for SafariI also checked that Element inherits
prototypes
from the EventTarget interface and it does ! (document.body.addEventListener == EventTarget.prototype.addEventListener
returnedtrue
)Safari just doesn't allow you to use the
EventTarget
interface in your own objects other than DOM elements. So I simply replicated the class to do it.