@@ -15,18 +15,25 @@ define([
1515 var originalMatchMedia , originalModernizr , stopEventFn ;
1616
1717 function extractStopEvent ( source ) {
18- var start = source . indexOf ( 'function stopEvent' ) ;
18+ let start = source . indexOf ( 'function stopEvent' ) ,
19+ braceStart ,
20+ depth ,
21+ i ,
22+ end ,
23+ ch ;
24+
1925 if ( start === - 1 ) {
2026 return undefined ;
2127 }
22- var braceStart = source . indexOf ( '{' , start ) ;
23- var depth = 0 , i = braceStart , end = - 1 ;
28+ braceStart = source . indexOf ( '{' , start ) ;
29+ depth = 0 , i = braceStart , end = - 1 ;
2430 for ( ; i < source . length ; i ++ ) {
25- var ch = source [ i ] ;
31+ ch = source [ i ] ;
2632 if ( ch === '{' ) {
2733 depth ++ ;
2834 } else if ( ch === '}' ) {
2935 depth -- ;
36+ // eslint-disable-next-line max-depth
3037 if ( depth === 0 ) {
3138 end = i + 1 ;
3239 break ;
@@ -37,7 +44,7 @@ define([
3744 return undefined ;
3845 }
3946 // eslint-disable-next-line no-new-func
40- return ( new Function ( 'return (' + source . slice ( start , end ) + ');' ) ) ( ) ;
47+ return new Function ( 'return (' + source . slice ( start , end ) + ');' ) ( ) ;
4148 }
4249
4350 beforeAll ( function ( ) {
@@ -66,33 +73,37 @@ define([
6673 }
6774
6875 it ( 'prevents default and stops propagation on mobile touchend' , function ( ) {
69- window . matchMedia = function ( ) { return { matches : true } ; } ;
7076 var e = mockEvent ( 'touchend' ) ;
77+
78+ window . matchMedia = function ( ) { return { matches : true } ; } ;
7179 stopEventFn ( e ) ;
7280 expect ( e . preventDefault ) . toHaveBeenCalled ( ) ;
7381 expect ( e . stopPropagation ) . toHaveBeenCalled ( ) ;
7482 } ) ;
7583
7684 it ( 'prevents default on desktop click when Modernizr.touch is false' , function ( ) {
85+ var e = mockEvent ( 'click' ) ;
86+
7787 window . matchMedia = function ( ) { return { matches : false } ; } ;
7888 window . Modernizr . touch = false ;
79- var e = mockEvent ( 'click' ) ;
8089 stopEventFn ( e ) ;
8190 expect ( e . preventDefault ) . toHaveBeenCalled ( ) ;
8291 } ) ;
8392
8493 it ( 'does not prevent default on desktop click when Modernizr.touch is true' , function ( ) {
94+ var e = mockEvent ( 'click' ) ;
95+
8596 window . matchMedia = function ( ) { return { matches : false } ; } ;
8697 window . Modernizr . touch = true ;
87- var e = mockEvent ( 'click' ) ;
8898 stopEventFn ( e ) ;
8999 expect ( e . preventDefault ) . not . toHaveBeenCalled ( ) ;
90100 } ) ;
91101
92102 it ( 'stops propagation when second argument is true' , function ( ) {
103+ var e = mockEvent ( 'click' ) ;
104+
93105 window . matchMedia = function ( ) { return { matches : false } ; } ;
94106 window . Modernizr . touch = false ;
95- var e = mockEvent ( 'click' ) ;
96107 stopEventFn ( e , true ) ;
97108 expect ( e . stopPropagation ) . toHaveBeenCalled ( ) ;
98109 } ) ;
0 commit comments