Skip to content

Commit

Permalink
rebase PointerEvent on top of MouseEvent
Browse files Browse the repository at this point in the history
According to documentation on MDN¹, the PointerEvent interface
inherits properties from MouseEvent, which in turn inherits from
UIEvent, and that inherits from Event.

Embed MouseEvent in PointerEvent type in order to gain access to
additional properties in PointerEvent.

This is similar to what was done to WheelEvent in Pull Request #77.

¹ https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent

GitHub-Pull-Request: #80
  • Loading branch information
dmitshur committed Jul 25, 2021
1 parent d4405f7 commit f030747
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func wrapEvent(o *js.Object) Event {
case js.Global.Get("PageTransitionEvent"):
return &PageTransitionEvent{ev}
case js.Global.Get("PointerEvent"):
return &PointerEvent{ev}
return &PointerEvent{&MouseEvent{UIEvent: &UIEvent{ev}}}
case js.Global.Get("PopStateEvent"):
return &PopStateEvent{ev}
case js.Global.Get("ProgressEvent"):
Expand Down Expand Up @@ -298,7 +298,7 @@ func (ev *MouseEvent) ModifierState(mod string) bool {
type MutationEvent struct{ *BasicEvent }
type OfflineAudioCompletionEvent struct{ *BasicEvent }
type PageTransitionEvent struct{ *BasicEvent }
type PointerEvent struct{ *BasicEvent }
type PointerEvent struct{ *MouseEvent }
type PopStateEvent struct{ *BasicEvent }
type ProgressEvent struct{ *BasicEvent }
type RelatedEvent struct{ *BasicEvent }
Expand Down
4 changes: 2 additions & 2 deletions v2/dom.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// +build js
// +build go1.14
//go:build js && go1.14
// +build js,go1.14

// Package dom provides Go bindings for the JavaScript DOM APIs.
//
Expand Down
4 changes: 2 additions & 2 deletions v2/dom_go113.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// +build js
// +build !go1.14
//go:build js && !go1.14
// +build js,!go1.14

// Package dom provides Go bindings for the JavaScript DOM APIs.
//
Expand Down
1 change: 1 addition & 0 deletions v2/dom_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build js
// +build js

package dom
Expand Down
8 changes: 4 additions & 4 deletions v2/events.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// +build js
// +build go1.14
//go:build js && go1.14
// +build js,go1.14

package dom

Expand Down Expand Up @@ -78,7 +78,7 @@ func wrapEvent(o js.Value) Event {
case c.Equal(js.Global().Get("PageTransitionEvent")):
return &PageTransitionEvent{ev}
case c.Equal(js.Global().Get("PointerEvent")):
return &PointerEvent{ev}
return &PointerEvent{&MouseEvent{&UIEvent{ev}}}
case c.Equal(js.Global().Get("PopStateEvent")):
return &PopStateEvent{ev}
case c.Equal(js.Global().Get("ProgressEvent")):
Expand Down Expand Up @@ -301,7 +301,7 @@ func (ev *MouseEvent) ModifierState(mod string) bool {
type MutationEvent struct{ *BasicEvent }
type OfflineAudioCompletionEvent struct{ *BasicEvent }
type PageTransitionEvent struct{ *BasicEvent }
type PointerEvent struct{ *BasicEvent }
type PointerEvent struct{ *MouseEvent }
type PopStateEvent struct{ *BasicEvent }
type ProgressEvent struct{ *BasicEvent }
type RelatedEvent struct{ *BasicEvent }
Expand Down
8 changes: 4 additions & 4 deletions v2/events_go113.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// +build js
// +build !go1.14
//go:build js && !go1.14
// +build js,!go1.14

package dom

Expand Down Expand Up @@ -78,7 +78,7 @@ func wrapEvent(o js.Value) Event {
case js.Global().Get("PageTransitionEvent"):
return &PageTransitionEvent{ev}
case js.Global().Get("PointerEvent"):
return &PointerEvent{ev}
return &PointerEvent{&MouseEvent{&UIEvent{ev}}}
case js.Global().Get("PopStateEvent"):
return &PopStateEvent{ev}
case js.Global().Get("ProgressEvent"):
Expand Down Expand Up @@ -301,7 +301,7 @@ func (ev *MouseEvent) ModifierState(mod string) bool {
type MutationEvent struct{ *BasicEvent }
type OfflineAudioCompletionEvent struct{ *BasicEvent }
type PageTransitionEvent struct{ *BasicEvent }
type PointerEvent struct{ *BasicEvent }
type PointerEvent struct{ *MouseEvent }
type PopStateEvent struct{ *BasicEvent }
type ProgressEvent struct{ *BasicEvent }
type RelatedEvent struct{ *BasicEvent }
Expand Down

0 comments on commit f030747

Please sign in to comment.