npm-dom / dom-event

Add/remove DOM events
http://npm.im/dom-event
34 stars 7 forks source link

Unable to add events to window via attachEvent #5

Closed phloe closed 9 years ago

phloe commented 9 years ago

Trying to add a scroll event on the window object fails in IE8:

"Object doesn't support this property or method"

Seems like you can't use call on window.attachEvent:

window.attachEvent.call(window, /*...*/);

https://github.com/npm-dom/dom-event/blob/master/index.js#L6

azer commented 9 years ago

fixed by 95b9e723a27da2e04bd3f816634e886c985625e4

phloe commented 9 years ago

@azer This issue wasn't actually fixed by 95b9e72 - it still uses .call.

Why not just do:

(element.removeEventListener || element.detachEvent)(event, callback, capture);

instead of:

(element.removeEventListener || element.detachEvent).call(element, event, callback, capture);

azer commented 9 years ago

@rasmusfl0e could u send a PR for that ? I couldn't merge your PR because it was refactoring the entire thing

phloe commented 9 years ago

@azer Done ;)