Skip to content

Commit

Permalink
feat: add offline/online events (testing-library#1205)
Browse files Browse the repository at this point in the history
  • Loading branch information
JCB-K authored Jan 16, 2023
1 parent 9f363af commit 0ce0c70
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/__tests__/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ const eventTypes = [
events: ['load', 'error'],
elementType: 'img',
},
{
type: '',
events: ['offline', 'online'],
elementType: 'window',
},
{
type: '',
events: ['load', 'error'],
Expand Down
9 changes: 9 additions & 0 deletions src/event-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,15 @@ export const eventMap = {
EventType: 'PopStateEvent',
defaultInit: {bubbles: true, cancelable: false},
},
// window events
offline: {
EventType: 'Event',
defaultInit: {bubbles: false, cancelable: false},
},
online: {
EventType: 'Event',
defaultInit: {bubbles: false, cancelable: false},
},
}

export const eventAliasMap = {
Expand Down
2 changes: 2 additions & 0 deletions types/events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export type EventType =
| 'pointerLeave'
| 'gotPointerCapture'
| 'lostPointerCapture'
| 'offline'
| 'online'

export type FireFunction = (
element: Document | Element | Window | Node,
Expand Down

0 comments on commit 0ce0c70

Please sign in to comment.