Skip to content

Commit

Permalink
facebook#6049 add support for onCancel and onClose event
Browse files Browse the repository at this point in the history
  • Loading branch information
ludvigsen committed Jan 26, 2017
1 parent 3c75593 commit 318563d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/renderers/dom/shared/ReactBrowserEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ var topEventMapping = {
topAnimationIteration: getVendorPrefixedEventName('animationiteration') || 'animationiteration',
topAnimationStart: getVendorPrefixedEventName('animationstart') || 'animationstart',
topBlur: 'blur',
topCancel: 'cancel',
topCanPlay: 'canplay',
topCanPlayThrough: 'canplaythrough',
topChange: 'change',
topClick: 'click',
topClose: 'close',
topCompositionEnd: 'compositionend',
topCompositionStart: 'compositionstart',
topCompositionUpdate: 'compositionupdate',
Expand Down Expand Up @@ -305,6 +307,24 @@ var ReactBrowserEventEmitter = Object.assign({}, ReactEventEmitterMixin, {
// to make sure blur and focus event listeners are only attached once
isListening.topBlur = true;
isListening.topFocus = true;
} else if (dependency === 'topCancel') {
if (isEventSupported('cancel', true)) {
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
'topCancel',
'cancel',
mountAt
);
}
isListening.topCancel = true;
} else if (dependency === 'topClose') {
if (isEventSupported('close', true)) {
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
'topClose',
'close',
mountAt
);
}
isListening.topClose = true;
} else if (topEventMapping.hasOwnProperty(dependency)) {
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
dependency,
Expand Down
4 changes: 4 additions & 0 deletions src/renderers/dom/shared/eventPlugins/SimpleEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ var topLevelEventsToDispatchConfig: {[key: TopLevelTypes]: DispatchConfig} = {};
'animationIteration',
'animationStart',
'blur',
'cancel',
'canPlay',
'canPlayThrough',
'click',
'close',
'contextMenu',
'copy',
'cut',
Expand Down Expand Up @@ -155,8 +157,10 @@ var SimpleEventPlugin: PluginModule<MouseEvent> = {
var EventConstructor;
switch (topLevelType) {
case 'topAbort':
case 'topCancel':
case 'topCanPlay':
case 'topCanPlayThrough':
case 'topClose':
case 'topDurationChange':
case 'topEmptied':
case 'topEncrypted':
Expand Down
2 changes: 2 additions & 0 deletions src/renderers/shared/shared/event/EventConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ var topLevelTypes = {
topAnimationIteration: null,
topAnimationStart: null,
topBlur: null,
topCancel: null,
topCanPlay: null,
topCanPlayThrough: null,
topChange: null,
topClick: null,
topClose: null,
topCompositionEnd: null,
topCompositionStart: null,
topCompositionUpdate: null,
Expand Down

0 comments on commit 318563d

Please sign in to comment.