| From | Sent On | Attachments |
|---|---|---|
| Patrick Mueller | Apr 13, 2012 8:31 am | |
| Filip Maj | Apr 14, 2012 10:48 am | |
| Anis KADRI | Apr 14, 2012 10:56 am | |
| Patrick Mueller | Apr 14, 2012 2:19 pm | |
| Filip Maj | Apr 14, 2012 2:21 pm | |
| gtan...@gmail.com | Apr 14, 2012 2:27 pm |
| Subject: | why are we monkey patching addEventListener()? | |
|---|---|---|
| From: | Patrick Mueller (pmue...@gmail.com) | |
| Date: | Apr 13, 2012 8:31:59 am | |
| List: | org.apache.incubator.callback-dev | |
Question about:
https://github.com/apache/incubator-cordova-js/blob/master/lib/cordova.js
specifically:
document.addEventListener = function(evt, handler, capture) {...} window.addEventListener = function(evt, handler, capture) {...} document.removeEventListener = function(evt, handler, capture) {...} window.removeEventListener = function(evt, handler, capture) {...}
The question is:
GREAT ODIN'S RAVEN WHY ARE WE DOING THIS?
Does the following just not work for user-created events?
event = document.createEvent('Events') event.initEvent(blah)
window.dispatchEvent(event) // or document.dispatchEvent(event)
I dislike monkey patching, and my natural inclination is to blame it when you see problem reports of the ilk "I never got the deviceready (or whatever) message".
OTOH, I do monkey patch these in weinre (I think - I used to, or something) so I can do some diagnostic work
If we have to, we have to.
But if we don't have to, I'd prefer we didn't.
If we have to on some platform, but not others, I'd prefer we only do it on platforms that we need to do it.
If we're doing it because there's (essentially) a magic linkage between these events and channels, and we muck with the "handlers" via the channels because they're magically linked, I'd prefer we didn't do that.
-- Patrick Mueller http://muellerware.org





