mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
move augmentClass definition above SyntheticEvent Proxy replacement (#10011)
This commit is contained in:
@@ -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 */
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user