Raynos / dom-delegator

Decorate elements with delegated events
MIT License
58 stars 16 forks source link

don't die when the event target is window #19

Closed neonstalwart closed 9 years ago

neonstalwart commented 9 years ago

when you scroll a page in ios in a way that hides the navigation and tab bars, it causes a resize to fire on documentElement even though window is the target (demo at http://jsbin.com/cuwikexefu). window.parentNode is undefined (rather than null) and so it means that getListener ends up calling EvStore with an undefined target.

this PR causes getListener to terminate with an undefined target.

neonstalwart commented 9 years ago

@Raynos

i'm not sure how you prefer to check for undefined. i would have just done if (target == null) but i think jshint was forcing === so i went with typeof target === "undefined"

another option would be to stop listening for 'resize' since usually it's fired on window anyhow which makes it kind of pointless in dom-delegator given that it listens for events on documentElement.

Raynos commented 9 years ago

lgtm.