@samitouri / QOS-React / commits / d8450845fe

#6049 add support for onCancel and onClose event (#6247)

Marius Skaar Ludvigsen committed Jan 31, 2017 at 15:10 UTC d8450845fe735b407133b1b3aa6a87e7c45679d5
3 files changed +26
src/renderers/dom/shared/ReactBrowserEventEmitter.js
+20
@@ -87,10 +87,12 @@ var topEventMapping = {
87 topAnimationIteration: getVendorPrefixedEventName('animationiteration') || 'animationiteration',
88 topAnimationStart: getVendorPrefixedEventName('animationstart') || 'animationstart',
89 topBlur: 'blur',
90 + topCancel: 'cancel',
91 topCanPlay: 'canplay',
92 topCanPlayThrough: 'canplaythrough',
93 topChange: 'change',
94 topClick: 'click',
95 + topClose: 'close',
96 topCompositionEnd: 'compositionend',
97 topCompositionStart: 'compositionstart',
98 topCompositionUpdate: 'compositionupdate',
@@ -305,6 +307,24 @@ var ReactBrowserEventEmitter = Object.assign({}, ReactEventEmitterMixin, {
307 // to make sure blur and focus event listeners are only attached once
308 isListening.topBlur = true;
309 isListening.topFocus = true;
310 + } else if (dependency === 'topCancel') {
311 + if (isEventSupported('cancel', true)) {
312 + ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
313 + 'topCancel',
314 + 'cancel',
315 + mountAt
316 + );
317 + }
318 + isListening.topCancel = true;
319 + } else if (dependency === 'topClose') {
320 + if (isEventSupported('close', true)) {
321 + ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
322 + 'topClose',
323 + 'close',
324 + mountAt
325 + );
326 + }
327 + isListening.topClose = true;
328 } else if (topEventMapping.hasOwnProperty(dependency)) {
329 ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
330 dependency,
src/renderers/dom/shared/eventPlugins/SimpleEventPlugin.js
+4
@@ -65,9 +65,11 @@ var topLevelEventsToDispatchConfig: {[key: TopLevelTypes]: DispatchConfig} = {};
65 'animationIteration',
66 'animationStart',
67 'blur',
68 + 'cancel',
69 'canPlay',
70 'canPlayThrough',
71 'click',
72 + 'close',
73 'contextMenu',
74 'copy',
75 'cut',
@@ -155,8 +157,10 @@ var SimpleEventPlugin: PluginModule<MouseEvent> = {
157 var EventConstructor;
158 switch (topLevelType) {
159 case 'topAbort':
160 + case 'topCancel':
161 case 'topCanPlay':
162 case 'topCanPlayThrough':
163 + case 'topClose':
164 case 'topDurationChange':
165 case 'topEmptied':
166 case 'topEncrypted':
src/renderers/shared/shared/event/EventConstants.js
+2
@@ -22,10 +22,12 @@ var topLevelTypes = {
22 topAnimationIteration: null,
23 topAnimationStart: null,
24 topBlur: null,
25 + topCancel: null,
26 topCanPlay: null,
27 topCanPlayThrough: null,
28 topChange: null,
29 topClick: null,
30 + topClose: null,
31 topCompositionEnd: null,
32 topCompositionStart: null,
33 topCompositionUpdate: null,