Skip to content

Commit

Permalink
Update on.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalarangelo authored Jan 5, 2018
1 parent 595be96 commit cd7c4b7
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions snippets/on.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

Adds an event listener to an element with the ability to use event delegation.

Use `EventTarget.addEventListener()` to add an event listener to an element. If there is a
`target` property supplied to the options object, ensure the event target matches the
target specified and then invoke the callback by supplying the correct `this` context.
Use `options` to pass options to `addEventListener` or omit it to use bubbling by default.
In order to use this function with `off`, the reference to the custom delegator function
is returned if the `target` option is specified. Omit `opts` to default to non-delegation
behavior and event bubbling.
Use `EventTarget.addEventListener()` to add an event listener to an element. If there is a `target` property supplied to the options object, ensure the event target matches the target specified and then invoke the callback by supplying the correct `this` context.
Returns a reference to the custom delegator function, in order to be possible to use with [`off`](#off).
Omit `opts` to default to non-delegation behavior and event bubbling.

```js
const on = (el, evt, fn, opts = {}) => {
Expand Down

0 comments on commit cd7c4b7

Please sign in to comment.