@@ -76,19 +76,20 @@ const TransitionEndEvents = [
76
76
'oTransitionEnd'
77
77
]
78
78
79
+ // Options for events
80
+ const EventOptions = { passive : true , capture : false }
81
+
79
82
/*
80
83
* Utility Methods
81
84
*/
82
85
83
86
// Better var type detection
84
- /* istanbul ignore next: not easy to test */
85
- function toType ( obj ) {
87
+ function toType ( obj ) /* istanbul ignore next: not easy to test */ {
86
88
return ( { } ) . toString . call ( obj ) . match ( / \s ( [ a - z A - Z ] + ) / ) [ 1 ] . toLowerCase ( )
87
89
}
88
90
89
91
// Check config properties for expected types
90
- /* istanbul ignore next: not easy to test */
91
- function typeCheckConfig ( componentName , config , configTypes ) {
92
+ function typeCheckConfig ( componentName , config , configTypes ) /* istanbul ignore next: not easy to test */ {
92
93
for ( const property in configTypes ) {
93
94
if ( Object . prototype . hasOwnProperty . call ( configTypes , property ) ) {
94
95
const expectedTypes = configTypes [ property ]
@@ -114,7 +115,7 @@ function typeCheckConfig (componentName, config, configTypes) {
114
115
*/
115
116
116
117
/* istanbul ignore next: not easy to test */
117
- class ScrollSpy {
118
+ class ScrollSpy /* istanbul ignore next: not easy to test */ {
118
119
constructor ( element , config , $root ) {
119
120
// The element we activate links in
120
121
this . $el = element
@@ -189,13 +190,13 @@ class ScrollSpy {
189
190
listen ( ) {
190
191
const scroller = this . getScroller ( )
191
192
if ( scroller && scroller . tagName !== 'BODY' ) {
192
- eventOn ( scroller , 'scroll' , this )
193
+ eventOn ( scroller , 'scroll' , this , EventOptions )
193
194
}
194
- eventOn ( window , 'scroll' , this )
195
- eventOn ( window , 'resize' , this )
196
- eventOn ( window , 'orientationchange' , this )
195
+ eventOn ( window , 'scroll' , this , EventOptions )
196
+ eventOn ( window , 'resize' , this , EventOptions )
197
+ eventOn ( window , 'orientationchange' , this , EventOptions )
197
198
TransitionEndEvents . forEach ( evtName => {
198
- eventOn ( window , evtName , this )
199
+ eventOn ( window , evtName , this , EventOptions )
199
200
} )
200
201
this . setObservers ( true )
201
202
// Scedule a refresh
@@ -206,13 +207,13 @@ class ScrollSpy {
206
207
const scroller = this . getScroller ( )
207
208
this . setObservers ( false )
208
209
if ( scroller && scroller . tagName !== 'BODY' ) {
209
- eventOff ( scroller , 'scroll' , this )
210
+ eventOff ( scroller , 'scroll' , this , EventOptions )
210
211
}
211
- eventOff ( window , 'scroll' , this )
212
- eventOff ( window , 'resize' , this )
213
- eventOff ( window , 'orientationchange' , this )
212
+ eventOff ( window , 'scroll' , this , EventOptions )
213
+ eventOff ( window , 'resize' , this , EventOptions )
214
+ eventOff ( window , 'orientationchange' , this , EventOptions )
214
215
TransitionEndEvents . forEach ( evtName => {
215
- eventOff ( window , evtName , this )
216
+ eventOff ( window , evtName , this , EventOptions )
216
217
} )
217
218
}
218
219
0 commit comments