Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dec3ed1

Browse files
walrusfruitcakenhunzaker
authored andcommitted
move augmentClass definition above SyntheticEvent Proxy replacement (facebook#10011)
1 parent 16ed333 commit dec3ed1

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

src/renderers/shared/stack/event/SyntheticEvent.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,33 @@ Object.assign(SyntheticEvent.prototype, {
210210

211211
SyntheticEvent.Interface = EventInterface;
212212

213+
/**
214+
* Helper to reduce boilerplate when creating subclasses.
215+
*
216+
* @param {function} Class
217+
* @param {?object} Interface
218+
*/
219+
SyntheticEvent.augmentClass = function(Class, Interface) {
220+
var Super = this;
221+
222+
var E = function() {};
223+
E.prototype = Super.prototype;
224+
var prototype = new E();
225+
226+
Object.assign(prototype, Class.prototype);
227+
Class.prototype = prototype;
228+
Class.prototype.constructor = Class;
229+
230+
Class.Interface = Object.assign({}, Super.Interface, Interface);
231+
Class.augmentClass = Super.augmentClass;
232+
233+
PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
234+
};
235+
236+
/** Proxying after everything set on SyntheticEvent
237+
* to resolve Proxy issue on some WebKit browsers
238+
* in which some Event properties are set to undefined (GH#10010)
239+
*/
213240
if (__DEV__) {
214241
if (isProxySupported) {
215242
/*eslint-disable no-func-assign */
@@ -243,28 +270,6 @@ if (__DEV__) {
243270
/*eslint-enable no-func-assign */
244271
}
245272
}
246-
/**
247-
* Helper to reduce boilerplate when creating subclasses.
248-
*
249-
* @param {function} Class
250-
* @param {?object} Interface
251-
*/
252-
SyntheticEvent.augmentClass = function(Class, Interface) {
253-
var Super = this;
254-
255-
var E = function() {};
256-
E.prototype = Super.prototype;
257-
var prototype = new E();
258-
259-
Object.assign(prototype, Class.prototype);
260-
Class.prototype = prototype;
261-
Class.prototype.constructor = Class;
262-
263-
Class.Interface = Object.assign({}, Super.Interface, Interface);
264-
Class.augmentClass = Super.augmentClass;
265-
266-
PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
267-
};
268273

269274
PooledClass.addPoolingTo(SyntheticEvent, PooledClass.fourArgumentPooler);
270275

0 commit comments

Comments
 (0)