Skip to content

Commit

Permalink
docs: update dispatch options parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban committed Apr 3, 2019
1 parent 993c52b commit 9c6b60e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion docs/misc/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ dispatch(host: Element, eventType: string, options): Boolean
* **arguments**:
* `host` - element instance
* `eventType` - type of the event to be dispatched
* `options` - object following `dispatchEvent` DOM API specification
* `options` - a dictionary, having the following optional fields:
* `bubbles`: a boolean indicating whether the event bubbles. The default is false
* `cancelable`: a boolean indicating whether the event can be cancelled. The default is false
* `composed`: a boolean indicating whether the event will trigger listeners outside of a shadow root The default is false
* `detail`: a custom data, which will be passed to an event listener
* **returns**:
* `false` if event is cancelable and at least one of the event handlers which handled this event called `preventDefault()`, otherwise it returns `true`
12 changes: 8 additions & 4 deletions docs/misc/utils.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Utils

## Dispatching Events
## Event Dispatcher

```typescript
dispatch(host: Element, eventType: string, options): Boolean
dispatch(host: Element, eventType: string, [options]): Boolean
```

* **arguments**:
* `host` - element instance
* `eventType` - type of the event to be dispatched
* `options` - object following `dispatchEvent` DOM API specification
* `options` - a dictionary, having the following optional fields:
* `bubbles`: a boolean indicating whether the event bubbles. The default is false
* `cancelable`: a boolean indicating whether the event can be cancelled. The default is false
* `composed`: a boolean indicating whether the event will trigger listeners outside of a shadow root The default is false
* `detail`: a custom data, which will be passed to an event listener
* **returns**:
* `false` if event is cancelable and at least one of the event handlers which handled this event called `preventDefault()`, otherwise it returns `true`

Expand All @@ -24,7 +28,7 @@ import { html, dispatch } from 'hybrids';
function change(host) {
host.value += 1;
// Trigger not bubbling `change` custom event
dispatch(host, 'change');
dispatch(host, 'change', { detail: host.value });
}

const MyElement = {
Expand Down

0 comments on commit 9c6b60e

Please sign in to comment.