Skip to content

Commit

Permalink
move augmentClass definition above SyntheticEvent Proxy replacement (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
walrusfruitcake authored and nhunzaker committed Aug 10, 2017
1 parent 16ed333 commit dec3ed1
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions src/renderers/shared/stack/event/SyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,33 @@ Object.assign(SyntheticEvent.prototype, {

SyntheticEvent.Interface = EventInterface;

/**
* Helper to reduce boilerplate when creating subclasses.
*
* @param {function} Class
* @param {?object} Interface
*/
SyntheticEvent.augmentClass = function(Class, Interface) {
var Super = this;

var E = function() {};
E.prototype = Super.prototype;
var prototype = new E();

Object.assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;

Class.Interface = Object.assign({}, Super.Interface, Interface);
Class.augmentClass = Super.augmentClass;

PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
};

/** Proxying after everything set on SyntheticEvent
* to resolve Proxy issue on some WebKit browsers
* in which some Event properties are set to undefined (GH#10010)
*/
if (__DEV__) {
if (isProxySupported) {
/*eslint-disable no-func-assign */
Expand Down Expand Up @@ -243,28 +270,6 @@ if (__DEV__) {
/*eslint-enable no-func-assign */
}
}
/**
* Helper to reduce boilerplate when creating subclasses.
*
* @param {function} Class
* @param {?object} Interface
*/
SyntheticEvent.augmentClass = function(Class, Interface) {
var Super = this;

var E = function() {};
E.prototype = Super.prototype;
var prototype = new E();

Object.assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;

Class.Interface = Object.assign({}, Super.Interface, Interface);
Class.augmentClass = Super.augmentClass;

PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
};

PooledClass.addPoolingTo(SyntheticEvent, PooledClass.fourArgumentPooler);

Expand Down

0 comments on commit dec3ed1

Please sign in to comment.