Check eventListener 'options' support & use same passive arg for removal#131
Check eventListener 'options' support & use same passive arg for removal#131caseywebdev merged 1 commit intocaseywebdev:masterfrom
Conversation
| } | ||
|
|
||
| componentDidMount() { | ||
| this.PASSIVE = supportsPassive() ? {passive: true} : false; |
There was a problem hiding this comment.
Can't this just be a constant in the module scope?
There was a problem hiding this comment.
Ah yes, I was thinking it would obviously crash on the server but the
try/catch or a process.browser check will clear that right up.
On Aug 25, 2016 11:36 AM, "Casey Foster" notifications@github.com wrote:
In react-list.es6
#131 (comment):@@ -72,6 +86,7 @@ module.exports = class ReactList extends Component {
}componentDidMount() {
- this.PASSIVE = supportsPassive() ? {passive: true} : false;
Can't this just be a constant in the module scope?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/orgsync/react-list/pull/131/files/7cc25b30658d7f879ac100b766896cd857b12e21#r76278814,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABJFP50txIkKvSqJdKZXzb5Fvfpb3vyhks5qjcR1gaJpZM4JtOs9
.
|
Updated @caseywebdev |
| // add/removeEventListener, we need to check, otherwise we will | ||
| // accidentally set `capture` with a truthy value. | ||
| const PASSIVE = (() => { | ||
| if (!process.browser) return false; |
There was a problem hiding this comment.
I'm not familiar with process.browser? AFAIK process isn't a standard global in the browser. Can we go with typeof window === 'undefined'?
There was a problem hiding this comment.
Ah I apologize - I write so many webpack/browserify modules that I just assume those globals. Will fix.
|
Updated |
|
Cool, LGTM, thanks! |
The DOM Spec indicates that
optionsshould be identical when removing event listeners.We also should check for event listener
optionssupport before usingpassive, lest we accidentally setcaptureby passing a truthy value and get different behavior on older browsers.