@samitouri / QOS-React / commits / b79619e52a

move augmentClass definition above SyntheticEvent Proxy replacement (#10011)

walrusfruitcake committed Jul 11, 2017 at 06:37 UTC b79619e52a86d141542af3d5364070a59824961d
1 file changed +27 -22
src/renderers/shared/shared/event/SyntheticEvent.js
+27 -22
@@ -210,6 +210,33 @@ Object.assign(SyntheticEvent.prototype, {
210
211 SyntheticEvent.Interface = EventInterface;
212
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 + */
240 if (__DEV__) {
241 if (isProxySupported) {
242 /*eslint-disable no-func-assign */
@@ -243,28 +270,6 @@ if (__DEV__) {
270 /*eslint-enable no-func-assign */
271 }
272 }
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 -};
273
274 PooledClass.addPoolingTo(SyntheticEvent, PooledClass.fourArgumentPooler);
275