77
88/* eslint valid-typeof: 0 */
99
10- import emptyFunction from 'fbjs/lib/emptyFunction' ;
1110import invariant from 'fbjs/lib/invariant' ;
1211import warning from 'fbjs/lib/warning' ;
1312
@@ -32,7 +31,9 @@ const EventInterface = {
3231 type : null ,
3332 target : null ,
3433 // currentTarget is set when dispatching; no use in copying it here
35- currentTarget : emptyFunction . thatReturnsNull ,
34+ currentTarget : function ( ) {
35+ return null ;
36+ } ,
3637 eventPhase : null ,
3738 bubbles : null ,
3839 cancelable : null ,
@@ -43,6 +44,14 @@ const EventInterface = {
4344 isTrusted : null ,
4445} ;
4546
47+ function functionThatReturnsTrue ( ) {
48+ return true ;
49+ }
50+
51+ function functionThatReturnsFalse ( ) {
52+ return false ;
53+ }
54+
4655/**
4756 * Synthetic events are dispatched by event plugins, typically in response to a
4857 * top-level event delegation handler.
@@ -103,11 +112,11 @@ function SyntheticEvent(
103112 ? nativeEvent . defaultPrevented
104113 : nativeEvent . returnValue === false ;
105114 if ( defaultPrevented ) {
106- this . isDefaultPrevented = emptyFunction . thatReturnsTrue ;
115+ this . isDefaultPrevented = functionThatReturnsTrue ;
107116 } else {
108- this . isDefaultPrevented = emptyFunction . thatReturnsFalse ;
117+ this . isDefaultPrevented = functionThatReturnsFalse ;
109118 }
110- this . isPropagationStopped = emptyFunction . thatReturnsFalse ;
119+ this . isPropagationStopped = functionThatReturnsFalse ;
111120 return this ;
112121}
113122
@@ -124,7 +133,7 @@ Object.assign(SyntheticEvent.prototype, {
124133 } else if ( typeof event . returnValue !== 'unknown' ) {
125134 event . returnValue = false ;
126135 }
127- this . isDefaultPrevented = emptyFunction . thatReturnsTrue ;
136+ this . isDefaultPrevented = functionThatReturnsTrue ;
128137 } ,
129138
130139 stopPropagation : function ( ) {
@@ -144,7 +153,7 @@ Object.assign(SyntheticEvent.prototype, {
144153 event . cancelBubble = true ;
145154 }
146155
147- this . isPropagationStopped = emptyFunction . thatReturnsTrue ;
156+ this . isPropagationStopped = functionThatReturnsTrue ;
148157 } ,
149158
150159 /**
@@ -153,15 +162,15 @@ Object.assign(SyntheticEvent.prototype, {
153162 * won't be added back into the pool.
154163 */
155164 persist : function ( ) {
156- this . isPersistent = emptyFunction . thatReturnsTrue ;
165+ this . isPersistent = functionThatReturnsTrue ;
157166 } ,
158167
159168 /**
160169 * Checks if this event should be released back into the pool.
161170 *
162171 * @return {boolean } True if this should not be released, false otherwise.
163172 */
164- isPersistent : emptyFunction . thatReturnsFalse ,
173+ isPersistent : functionThatReturnsFalse ,
165174
166175 /**
167176 * `PooledClass` looks for `destructor` on each instance it releases.
@@ -191,12 +200,12 @@ Object.assign(SyntheticEvent.prototype, {
191200 Object . defineProperty (
192201 this ,
193202 'preventDefault' ,
194- getPooledWarningPropertyDefinition ( 'preventDefault' , emptyFunction ) ,
203+ getPooledWarningPropertyDefinition ( 'preventDefault' , ( ) => { } ) ,
195204 ) ;
196205 Object . defineProperty (
197206 this ,
198207 'stopPropagation' ,
199- getPooledWarningPropertyDefinition ( 'stopPropagation' , emptyFunction ) ,
208+ getPooledWarningPropertyDefinition ( 'stopPropagation' , ( ) => { } ) ,
200209 ) ;
201210 }
202211 } ,
0 commit comments