Skip to content
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

Add onToggle event to details tag #8831

Merged
merged 4 commits into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions docs/docs/reference-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The event handlers below are triggered by an event in the bubbling phase. To reg
- [Image Events](#image-events)
- [Animation Events](#animation-events)
- [Transition Events](#transition-events)
- [Other Events](#other-events)

* * *

Expand Down Expand Up @@ -286,9 +287,9 @@ number deltaZ
Event names:

```
onAbort onCanPlay onCanPlayThrough onDurationChange onEmptied onEncrypted
onEnded onError onLoadedData onLoadedMetadata onLoadStart onPause onPlay
onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend
onAbort onCanPlay onCanPlayThrough onDurationChange onEmptied onEncrypted
onEnded onError onLoadedData onLoadedMetadata onLoadStart onPause onPlay
onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend
onTimeUpdate onVolumeChange onWaiting
```

Expand Down Expand Up @@ -338,3 +339,12 @@ string pseudoElement
float elapsedTime
```

* * *

### Other Events

Event names:

```
onToggle
```
8 changes: 8 additions & 0 deletions src/renderers/dom/fiber/ReactDOMFiberComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ function trapBubbledEventsLocal(node : Element, tag : string) {
node
);
break;
case 'details':
ReactBrowserEventEmitter.trapBubbledEvent(
'topToggle',
'toggle',
node
);
break;
}
}

Expand Down Expand Up @@ -555,6 +562,7 @@ var ReactDOMFiberComponent = {
case 'object':
case 'source':
case 'video':
case 'details':
trapBubbledEventsLocal(domElement, tag);
props = rawProps;
break;
Expand Down
1 change: 1 addition & 0 deletions src/renderers/dom/shared/ReactBrowserEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ var topEventMapping = {
topSuspend: 'suspend',
topTextInput: 'textInput',
topTimeUpdate: 'timeupdate',
topToggle: 'toggle',
topTouchCancel: 'touchcancel',
topTouchEnd: 'touchend',
topTouchMove: 'touchmove',
Expand Down
2 changes: 2 additions & 0 deletions src/renderers/dom/shared/eventPlugins/SimpleEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ var topLevelEventsToDispatchConfig: {[key: TopLevelTypes]: DispatchConfig} = {};
'submit',
'suspend',
'timeUpdate',
'toggle',
'touchCancel',
'touchEnd',
'touchMove',
Expand Down Expand Up @@ -180,6 +181,7 @@ var SimpleEventPlugin: PluginModule<MouseEvent> = {
case 'topSubmit':
case 'topSuspend':
case 'topTimeUpdate':
case 'topToggle':
case 'topVolumeChange':
case 'topWaiting':
// HTML Events
Expand Down
10 changes: 10 additions & 0 deletions src/renderers/dom/stack/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,15 @@ function trapBubbledEventsLocal() {
),
];
break;
case 'details':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be replicated in ReactDOMFiberComponent which is a fork.

inst._wrapperState.listeners = [
ReactBrowserEventEmitter.trapBubbledEvent(
'topToggle',
'toggle',
node
),
];
break;
}
}

Expand Down Expand Up @@ -465,6 +474,7 @@ ReactDOMComponent.Mixin = {
case 'object':
case 'source':
case 'video':
case 'details':
this._wrapperState = {
listeners: null,
};
Expand Down
1 change: 1 addition & 0 deletions src/renderers/shared/shared/event/EventConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var topLevelTypes = {
topSuspend: null,
topTextInput: null,
topTimeUpdate: null,
topToggle: null,
topTouchCancel: null,
topTouchEnd: null,
topTouchMove: null,
Expand Down