@@ -68,7 +68,7 @@ export function CodeMirror(place, options) {
6868
6969 // Override magic textarea content restore that IE sometimes does
7070 // on our hidden textarea on reload
71- if ( ie && ie_version < 11 ) setTimeout ( function ( ) { cm . display . input . reset ( true ) } , 20 )
71+ if ( ie && ie_version < 11 ) setTimeout ( ( ) => cm . display . input . reset ( true ) , 20 )
7272
7373 registerEventHandlers ( this )
7474 ensureGlobalHandlers ( )
@@ -108,7 +108,7 @@ function registerEventHandlers(cm) {
108108 on ( d . scroller , "mousedown" , operation ( cm , onMouseDown ) )
109109 // Older IE's will not fire a second mousedown for a double click
110110 if ( ie && ie_version < 11 )
111- on ( d . scroller , "dblclick" , operation ( cm , function ( e ) {
111+ on ( d . scroller , "dblclick" , operation ( cm , e => {
112112 if ( signalDOMEvent ( cm , e ) ) return
113113 let pos = posFromMouse ( cm , e )
114114 if ( ! pos || clickInGutter ( cm , e ) || eventInWidget ( cm . display , e ) ) return
@@ -117,17 +117,17 @@ function registerEventHandlers(cm) {
117117 extendSelection ( cm . doc , word . anchor , word . head )
118118 } ) )
119119 else
120- on ( d . scroller , "dblclick" , function ( e ) { signalDOMEvent ( cm , e ) || e_preventDefault ( e ) } )
120+ on ( d . scroller , "dblclick" , e => signalDOMEvent ( cm , e ) || e_preventDefault ( e ) )
121121 // Some browsers fire contextmenu *after* opening the menu, at
122122 // which point we can't mess with it anymore. Context menu is
123123 // handled in onMouseDown for these browsers.
124- if ( ! captureRightClick ) on ( d . scroller , "contextmenu" , function ( e ) { onContextMenu ( cm , e ) } )
124+ if ( ! captureRightClick ) on ( d . scroller , "contextmenu" , e => onContextMenu ( cm , e ) )
125125
126126 // Used to suppress mouse event handling when a touch happens
127127 let touchFinished , prevTouch = { end : 0 }
128128 function finishTouch ( ) {
129129 if ( d . activeTouch ) {
130- touchFinished = setTimeout ( function ( ) { d . activeTouch = null } , 1000 )
130+ touchFinished = setTimeout ( ( ) => d . activeTouch = null , 1000 )
131131 prevTouch = d . activeTouch
132132 prevTouch . end = + new Date
133133 }
@@ -142,7 +142,7 @@ function registerEventHandlers(cm) {
142142 let dx = other . left - touch . left , dy = other . top - touch . top
143143 return dx * dx + dy * dy > 20 * 20
144144 }
145- on ( d . scroller , "touchstart" , function ( e ) {
145+ on ( d . scroller , "touchstart" , e => {
146146 if ( ! signalDOMEvent ( cm , e ) && ! isMouseLikeTouchEvent ( e ) ) {
147147 clearTimeout ( touchFinished )
148148 let now = + new Date
@@ -154,10 +154,10 @@ function registerEventHandlers(cm) {
154154 }
155155 }
156156 } )
157- on ( d . scroller , "touchmove" , function ( ) {
157+ on ( d . scroller , "touchmove" , ( ) => {
158158 if ( d . activeTouch ) d . activeTouch . moved = true
159159 } )
160- on ( d . scroller , "touchend" , function ( e ) {
160+ on ( d . scroller , "touchend" , e => {
161161 let touch = d . activeTouch
162162 if ( touch && ! eventInWidget ( d , e ) && touch . left != null &&
163163 ! touch . moved && new Date - touch . start < 300 ) {
@@ -178,7 +178,7 @@ function registerEventHandlers(cm) {
178178
179179 // Sync scrolling between fake scrollbars and real scrollable
180180 // area, ensure viewport is updated when scrolling.
181- on ( d . scroller , "scroll" , function ( ) {
181+ on ( d . scroller , "scroll" , ( ) => {
182182 if ( d . scroller . clientHeight ) {
183183 setScrollTop ( cm , d . scroller . scrollTop )
184184 setScrollLeft ( cm , d . scroller . scrollLeft , true )
@@ -187,27 +187,27 @@ function registerEventHandlers(cm) {
187187 } )
188188
189189 // Listen to wheel events in order to try and update the viewport on time.
190- on ( d . scroller , "mousewheel" , function ( e ) { onScrollWheel ( cm , e ) } )
191- on ( d . scroller , "DOMMouseScroll" , function ( e ) { onScrollWheel ( cm , e ) } )
190+ on ( d . scroller , "mousewheel" , e => onScrollWheel ( cm , e ) )
191+ on ( d . scroller , "DOMMouseScroll" , e => onScrollWheel ( cm , e ) )
192192
193193 // Prevent wrapper from ever scrolling
194- on ( d . wrapper , "scroll" , function ( ) { d . wrapper . scrollTop = d . wrapper . scrollLeft = 0 } )
194+ on ( d . wrapper , "scroll" , ( ) => d . wrapper . scrollTop = d . wrapper . scrollLeft = 0 )
195195
196196 d . dragFunctions = {
197- enter : function ( e ) { if ( ! signalDOMEvent ( cm , e ) ) e_stop ( e ) } ,
198- over : function ( e ) { if ( ! signalDOMEvent ( cm , e ) ) { onDragOver ( cm , e ) ; e_stop ( e ) } } ,
199- start : function ( e ) { onDragStart ( cm , e ) } ,
197+ enter : e => { if ( ! signalDOMEvent ( cm , e ) ) e_stop ( e ) } ,
198+ over : e => { if ( ! signalDOMEvent ( cm , e ) ) { onDragOver ( cm , e ) ; e_stop ( e ) } } ,
199+ start : e => onDragStart ( cm , e ) ,
200200 drop : operation ( cm , onDrop ) ,
201- leave : function ( e ) { if ( ! signalDOMEvent ( cm , e ) ) { clearDragCursor ( cm ) } }
201+ leave : e => { if ( ! signalDOMEvent ( cm , e ) ) { clearDragCursor ( cm ) } }
202202 }
203203
204204 let inp = d . input . getField ( )
205- on ( inp , "keyup" , function ( e ) { onKeyUp . call ( cm , e ) } )
205+ on ( inp , "keyup" , e => onKeyUp . call ( cm , e ) )
206206 on ( inp , "keydown" , operation ( cm , onKeyDown ) )
207207 on ( inp , "keypress" , operation ( cm , onKeyPress ) )
208- on ( inp , "focus" , function ( e ) { onFocus ( cm , e ) } )
209- on ( inp , "blur" , function ( e ) { onBlur ( cm , e ) } )
208+ on ( inp , "focus" , e => onFocus ( cm , e ) )
209+ on ( inp , "blur" , e => onBlur ( cm , e ) )
210210}
211211
212212let initHooks = [ ]
213- CodeMirror . defineInitHook = function ( f ) { initHooks . push ( f ) }
213+ CodeMirror . defineInitHook = f => initHooks . push ( f )
0 commit comments