File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,22 @@ const SIZE_KEYS = {x: 'width', y: 'height'};
2323
2424const NOOP = ( ) => { } ;
2525
26- const PASSIVE = { passive : true } ;
26+ // If a browser doesn't support the `options` argument to
27+ // add/removeEventListener, we need to check, otherwise we will
28+ // accidentally set `capture` with a truthy value.
29+ const PASSIVE = ( ( ) => {
30+ if ( typeof window === 'undefined' ) return false ;
31+ let hasSupport = false ;
32+ try {
33+ document . createElement ( 'div' ) . addEventListener ( 'test' , NOOP , {
34+ get passive ( ) {
35+ hasSupport = true ;
36+ return false ;
37+ }
38+ } ) ;
39+ } catch ( e ) { }
40+ return hasSupport ;
41+ } ( ) ? { passive : true } : false ;
2742
2843module . exports = class ReactList extends Component {
2944 static displayName = 'ReactList' ;
@@ -87,8 +102,8 @@ module.exports = class ReactList extends Component {
87102
88103 componentWillUnmount ( ) {
89104 window . removeEventListener ( 'resize' , this . updateFrame ) ;
90- this . scrollParent . removeEventListener ( 'scroll' , this . updateFrame ) ;
91- this . scrollParent . removeEventListener ( 'mousewheel' , NOOP ) ;
105+ this . scrollParent . removeEventListener ( 'scroll' , this . updateFrame , PASSIVE ) ;
106+ this . scrollParent . removeEventListener ( 'mousewheel' , NOOP , PASSIVE ) ;
92107 }
93108
94109 getOffset ( el ) {
You can’t perform that action at this time.
0 commit comments