Skip to content

fix: use current event modifiers syntax in render function #302

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

Closed
Closed
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
35 changes: 20 additions & 15 deletions src/guide/render-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,27 +295,32 @@ render() {

#### Event Modifiers

For the `.passive`, `.capture`, and `.once` event modifiers, Vue offers object syntax of the handler:
For the `.passive`, `.capture`, and `.once` event modifiers, Vue offers a special JSX-friendly syntax - no dots and the prop name has to be in the camelCase notation.
We can also combine multiple event modifiers, e.g., to use both `.capture` and `.once` event modifiers, the prop name would be `onMouseOverCaptureOnce`.

For example:

```javascript
render() {
return Vue.h('input', {
onClick: {
handler: this.doThisInCapturingMode,
capture: true
},
onKeyUp: {
handler: this.doThisOnce,
once: true
},
onMouseOver: {
handler: this.doThisOnceInCapturingMode,
once: true,
capture: true
return Vue.h(
'div',
{
// `.passive` modifier
onScrollPassive: this.doThisInPassiveMode,
},
})
[
Vue.h('input', {
// `.capture` modifier
onClickCapture: this.doThisInCapturingMode,

// `.once` modifier
onKeyUpOnce: this.doThisOnce,

// Both `.capture` and `.once` modifier
onMouseOverCaptureOnce: this.doThisOnceInCapturingMode,
})
]
)
}
```

Expand Down