-
Notifications
You must be signed in to change notification settings - Fork 47.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop some top-level events from the list #11912
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,19 +10,16 @@ import getVendorPrefixedEventName from './getVendorPrefixedEventName'; | |
/** | ||
* Types of raw signals from the browser caught at the top level. | ||
* | ||
* For events like 'submit' which don't consistently bubble (which we | ||
* trap at a lower node than `document`), binding at `document` would | ||
* cause duplicate events so we don't include them here. | ||
* For events like 'submit' or audio/video events which don't consistently | ||
* bubble (which we trap at a lower node than `document`), binding | ||
* at `document` would cause duplicate events so we don't include them here. | ||
*/ | ||
const topLevelTypes = { | ||
topAbort: 'abort', | ||
export const topLevelTypes = { | ||
topAnimationEnd: getVendorPrefixedEventName('animationend'), | ||
topAnimationIteration: getVendorPrefixedEventName('animationiteration'), | ||
topAnimationStart: getVendorPrefixedEventName('animationstart'), | ||
topBlur: 'blur', | ||
topCancel: 'cancel', | ||
topCanPlay: 'canplay', | ||
topCanPlayThrough: 'canplaythrough', | ||
topChange: 'change', | ||
topClick: 'click', | ||
topClose: 'close', | ||
|
@@ -41,54 +38,60 @@ const topLevelTypes = { | |
topDragOver: 'dragover', | ||
topDragStart: 'dragstart', | ||
topDrop: 'drop', | ||
topDurationChange: 'durationchange', | ||
topEmptied: 'emptied', | ||
topEncrypted: 'encrypted', | ||
topEnded: 'ended', | ||
topError: 'error', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one also fires for JS errors and images (not just media) but AFAIK it doesn't truly bubble either way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. It does not But it does capture. We might be able to attach them at the top level using capture to avoid eagerly attaching a listener to each element. |
||
topFocus: 'focus', | ||
topInput: 'input', | ||
topKeyDown: 'keydown', | ||
topKeyPress: 'keypress', | ||
topKeyUp: 'keyup', | ||
topLoadedData: 'loadeddata', | ||
topLoad: 'load', | ||
topLoadedMetadata: 'loadedmetadata', | ||
topLoadStart: 'loadstart', | ||
topMouseDown: 'mousedown', | ||
topMouseMove: 'mousemove', | ||
topMouseOut: 'mouseout', | ||
topMouseOver: 'mouseover', | ||
topMouseUp: 'mouseup', | ||
topPaste: 'paste', | ||
topScroll: 'scroll', | ||
topSelectionChange: 'selectionchange', | ||
topTextInput: 'textInput', | ||
topToggle: 'toggle', | ||
topTouchCancel: 'touchcancel', | ||
topTouchEnd: 'touchend', | ||
topTouchMove: 'touchmove', | ||
topTouchStart: 'touchstart', | ||
topTransitionEnd: getVendorPrefixedEventName('transitionend'), | ||
topWheel: 'wheel', | ||
}; | ||
|
||
// There are so many media events, it makes sense to just | ||
// maintain a list of them. Note these aren't technically | ||
// "top-level" since they don't bubble. We should come up | ||
// with a better naming convention if we come to refactoring | ||
// the event system. | ||
export const mediaEventTypes = { | ||
topAbort: 'abort', | ||
topCanPlay: 'canplay', | ||
topCanPlayThrough: 'canplaythrough', | ||
topDurationChange: 'durationchange', | ||
topEmptied: 'emptied', | ||
topEncrypted: 'encrypted', | ||
topEnded: 'ended', | ||
topError: 'error', | ||
topLoadedData: 'loadeddata', | ||
topLoadedMetadata: 'loadedmetadata', | ||
topLoadStart: 'loadstart', | ||
topPause: 'pause', | ||
topPlay: 'play', | ||
topPlaying: 'playing', | ||
topProgress: 'progress', | ||
topRateChange: 'ratechange', | ||
topScroll: 'scroll', | ||
topSeeked: 'seeked', | ||
topSeeking: 'seeking', | ||
topSelectionChange: 'selectionchange', | ||
topStalled: 'stalled', | ||
topSuspend: 'suspend', | ||
topTextInput: 'textInput', | ||
topTimeUpdate: 'timeupdate', | ||
topToggle: 'toggle', | ||
topTouchCancel: 'touchcancel', | ||
topTouchEnd: 'touchend', | ||
topTouchMove: 'touchmove', | ||
topTouchStart: 'touchstart', | ||
topTransitionEnd: getVendorPrefixedEventName('transitionend'), | ||
topVolumeChange: 'volumechange', | ||
topWaiting: 'waiting', | ||
topWheel: 'wheel', | ||
}; | ||
|
||
export type TopLevelTypes = $Enum<typeof topLevelTypes>; | ||
|
||
const BrowserEventConstants = { | ||
topLevelTypes, | ||
}; | ||
|
||
export default BrowserEventConstants; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ import { | |
import SyntheticEvent from 'events/SyntheticEvent'; | ||
import invariant from 'fbjs/lib/invariant'; | ||
|
||
import BrowserEventConstants from '../events/BrowserEventConstants'; | ||
import {topLevelTypes} from '../events/BrowserEventConstants'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops I think this might not be enough now? We need to do the same for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah man. I think you're right. Darn. |
||
|
||
const {findDOMNode} = ReactDOM; | ||
const { | ||
|
@@ -30,8 +30,6 @@ const { | |
ReactDOMEventListener, | ||
} = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
|
||
const topLevelTypes = BrowserEventConstants.topLevelTypes; | ||
|
||
function Event(suffix) {} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trapBubbledEvent
is kind of a confusing name now since it's attaching the listener directly to the event target in some cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. It's more like "attach this event locally to emulate bubbling"