Skip to content

Commit 8912b19

Browse files
LanayxMangelMaxime
andauthored
Cleaned up and improve number of DOM events (#144)
Co-authored-by: Maxime Mangel <[email protected]>
1 parent 3e168c9 commit 8912b19

File tree

4 files changed

+54
-23
lines changed

4 files changed

+54
-23
lines changed

src/Dom/Browser.Dom.fs

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ type [<AllowNullLiteral; Global>] Document =
170170
abstract onfocus: (FocusEvent -> unit) with get, set
171171
abstract onfullscreenchange: (Event -> unit) with get, set
172172
abstract onfullscreenerror: (Event -> unit) with get, set
173-
abstract oninput: (Event -> unit) with get, set
173+
abstract oninput: (InputEvent -> unit) with get, set
174174
/// Fires when the user presses a key.
175175
abstract onkeydown: (KeyboardEvent -> unit) with get, set
176176
/// Fires when the user presses an alphanumeric key.
@@ -233,6 +233,7 @@ type [<AllowNullLiteral; Global>] Document =
233233
abstract onsuspend: (Event -> unit) with get, set
234234
/// Occurs to indicate the current playback position.
235235
abstract ontimeupdate: (Event -> unit) with get, set
236+
abstract ontoggle: (ToggleEvent -> unit) with get, set
236237
abstract ontouchcancel: (TouchEvent -> unit) with get, set
237238
abstract ontouchend: (TouchEvent -> unit) with get, set
238239
abstract ontouchmove: (TouchEvent -> unit) with get, set
@@ -997,7 +998,7 @@ type [<AllowNullLiteral; Global>] Window =
997998
abstract onselect: (UIEvent -> unit) with get, set
998999
abstract onstalled: (Event -> unit) with get, set
9991000
abstract onstorage: (StorageEvent -> unit) with get, set
1000-
abstract onsubmit: (Event -> unit) with get, set
1001+
abstract onsubmit: (SubmitEvent -> unit) with get, set
10011002
abstract onsuspend: (Event -> unit) with get, set
10021003
abstract ontimeupdate: (Event -> unit) with get, set
10031004
abstract ongamepadconnected: (GamepadEvent -> unit) with get, set
@@ -2877,6 +2878,7 @@ type [<AllowNullLiteral; Global>] AnimationEvent =
28772878
inherit Event
28782879
abstract animationName: string with get, set
28792880
abstract elapsedTime: float with get, set
2881+
abstract pseudoElement: string with get, set
28802882

28812883
type [<AllowNullLiteral; Global>] MouseEvent =
28822884
inherit UIEvent
@@ -2937,6 +2939,7 @@ type [<AllowNullLiteral; Global>] DataTransfer =
29372939
abstract clearData: ?format: string -> bool
29382940
abstract getData: format: string -> string
29392941
abstract setData: format: string * data: string -> bool
2942+
abstract setDragImage: image: Element * x: float * y: float -> unit
29402943

29412944
type [<AllowNullLiteral; Global>] DataTransferItem =
29422945
abstract kind: string
@@ -2958,20 +2961,18 @@ type [<AllowNullLiteral; Global>] FocusEvent =
29582961

29592962
type [<AllowNullLiteral; Global>] PointerEvent =
29602963
inherit MouseEvent
2961-
abstract currentPoint: obj
29622964
abstract height: float
2963-
abstract hwTimestamp: float
2964-
abstract intermediatePoints: obj
29652965
abstract isPrimary: bool
29662966
abstract pointerId: float
2967-
abstract pointerType: obj
2967+
abstract pointerType: string
29682968
abstract pressure: float
2969-
abstract rotation: float
2969+
abstract tangentialPressure: float
29702970
abstract tiltX: float
29712971
abstract tiltY: float
2972+
abstract twist: float
29722973
abstract width: float
2973-
abstract getCurrentPoint: element: Element -> unit
2974-
abstract getIntermediatePoints: element: Element -> unit
2974+
abstract getCoalescedEvents: unit -> PointerEvent[]
2975+
abstract getPredictedEvents: unit -> PointerEvent[]
29752976

29762977
type [<AllowNullLiteral; Global>] PopStateEvent =
29772978
inherit Event
@@ -2980,22 +2981,18 @@ type [<AllowNullLiteral; Global>] PopStateEvent =
29802981
type [<AllowNullLiteral; Global>] KeyboardEvent =
29812982
inherit UIEvent
29822983
abstract altKey: bool
2983-
abstract char: string
2984+
[<Obsolete("event.charCode is deprecated see https://developer.mozilla.org/docs/Web/API/KeyboardEvent/charCode for more information")>]
29842985
abstract charCode: float
2986+
abstract code: string
29852987
abstract ctrlKey: bool
29862988
abstract key: string
2987-
[<Obsolete("event.keyCode is deprecated see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode for more information")>]
2989+
[<Obsolete("event.keyCode is deprecated see https://developer.mozilla.org/docs/Web/API/KeyboardEvent/keyCode for more information")>]
29882990
abstract keyCode: float
2989-
abstract code: string
2990-
abstract locale: string
29912991
abstract location: float
29922992
abstract metaKey: bool
29932993
abstract repeat: bool
29942994
abstract shiftKey: bool
2995-
abstract which: float
2996-
abstract DOM_KEY_LOCATION_JOYSTICK: float
29972995
abstract DOM_KEY_LOCATION_LEFT: float
2998-
abstract DOM_KEY_LOCATION_MOBILE: float
29992996
abstract DOM_KEY_LOCATION_NUMPAD: float
30002997
abstract DOM_KEY_LOCATION_RIGHT: float
30012998
abstract DOM_KEY_LOCATION_STANDARD: float
@@ -3005,6 +3002,7 @@ type [<AllowNullLiteral; Global>] ProgressEvent =
30053002
inherit Event
30063003
abstract lengthComputable: bool
30073004
abstract loaded: float
3005+
abstract target: EventTarget
30083006
abstract total: float
30093007

30103008
type [<AllowNullLiteral; Global>] Touch =
@@ -3069,6 +3067,7 @@ type [<AllowNullLiteral; Global>] TransitionEvent =
30693067
inherit Event
30703068
abstract elapsedTime: float with get, set
30713069
abstract propertyName: string with get, set
3070+
abstract pseudoElement: string with get, set
30723071

30733072
type [<AllowNullLiteral; Global>] PageTransitionEvent =
30743073
inherit Event
@@ -3092,10 +3091,30 @@ type [<AllowNullLiteral; Global>] WheelEvent =
30923091
abstract DOM_DELTA_LINE: float
30933092
abstract DOM_DELTA_PAGE: float
30943093
abstract DOM_DELTA_PIXEL: float
3095-
abstract getCurrentPoint: element: Element -> unit
30963094

3097-
// type [<AllowNullLiteral>] WheelEventType =
3098-
// abstract DOM_DELTA_LINE: float
3099-
// abstract DOM_DELTA_PAGE: float
3100-
// abstract DOM_DELTA_PIXEL: float
3101-
// [<Emit("new $0($1...)")>] abstract Create: typeArg: string * ?eventInitDict: WheelEventInit -> WheelEvent
3095+
type [<AllowNullLiteral; Global>] AbstractRange =
3096+
abstract collapsed: bool
3097+
abstract endContainer: Node
3098+
abstract endOffset: float
3099+
abstract startContainer: Node
3100+
abstract startOffset: float
3101+
3102+
type StaticRange =
3103+
inherit AbstractRange
3104+
3105+
type [<AllowNullLiteral; Global>] InputEvent =
3106+
inherit UIEvent
3107+
abstract data: string
3108+
abstract dataTransfer: DataTransfer
3109+
abstract inputType: string
3110+
abstract isComposing: bool
3111+
abstract getTargetRanges: unit -> StaticRange[]
3112+
3113+
type [<AllowNullLiteral; Global>] ToggleEvent =
3114+
inherit Event
3115+
abstract newState: string
3116+
abstract oldState: string
3117+
3118+
type [<AllowNullLiteral; Global>] SubmitEvent =
3119+
inherit Event
3120+
abstract submitter: HTMLElement

src/Dom/RELEASE_NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 2.18.0
2+
3+
* Better type event by replacing `Event` with things like `InputEvent` (by @Lanayx)
4+
* Add missing event properties (by @Lanayx)
5+
* Remove incorrect APIs (by @Lanayx)
6+
17
### 2.17.0
28

39
* Fix #137: Remove `Worker` related types, use `Fable.Browser.Worker` if needed (by @MangelMaxime)

src/Event/Browser.Event.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ open Fable.Core
55

66
type [<AllowNullLiteral; Global>] Event =
77
abstract bubbles: bool with get, set
8-
abstract cancelBubble: bool with get, set
98
abstract cancelable: bool with get, set
9+
abstract composed: bool with get, set
1010
abstract currentTarget: EventTarget with get, set
1111
abstract defaultPrevented: bool with get, set
1212
abstract eventPhase: float with get, set
@@ -18,6 +18,8 @@ type [<AllowNullLiteral; Global>] Event =
1818
abstract AT_TARGET: float with get, set
1919
abstract BUBBLING_PHASE: float with get, set
2020
abstract CAPTURING_PHASE: float with get, set
21+
abstract cancelBubble: unit -> unit
22+
abstract composedPath: unit -> EventTarget[]
2123
abstract initEvent: eventTypeArg: string * canBubbleArg: bool * cancelableArg: bool -> unit
2224
abstract preventDefault: unit -> unit
2325
abstract stopImmediatePropagation: unit -> unit

src/Event/RELEASE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 1.7.0
2+
3+
* Add `Event.compose`, `Event.cancelBubble` and `Event.composedPath` (by @Lanayx)
4+
15
### 1.6.0
26

37
* Align Fable.Core version to 3.2.8 for all of fable-browser packages

0 commit comments

Comments
 (0)