From ebaba6fa95cc1b91d100c0ef135e163e4bcf707b Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sun, 21 Jul 2024 21:30:22 -0400 Subject: [PATCH 1/2] add PointerEvent.PointerID and PointerEvent.PointerType See https://developer.mozilla.org/docs/Web/API/PointerEvent/pointerId and https://developer.mozilla.org/docs/Web/API/PointerEvent/pointerType. --- events.go | 10 ++++++++-- v2/events.go | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/events.go b/events.go index 1faccf7..01db7e8 100644 --- a/events.go +++ b/events.go @@ -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{&MouseEvent{UIEvent: &UIEvent{ev}}} + return &PointerEvent{MouseEvent: &MouseEvent{UIEvent: &UIEvent{ev}}} case js.Global.Get("PopStateEvent"): return &PopStateEvent{ev} case js.Global.Get("ProgressEvent"): @@ -307,7 +307,13 @@ func (ev *MouseEvent) ModifierState(mod string) bool { type MutationEvent struct{ *BasicEvent } type OfflineAudioCompletionEvent struct{ *BasicEvent } type PageTransitionEvent struct{ *BasicEvent } -type PointerEvent struct{ *MouseEvent } + +type PointerEvent struct { + *MouseEvent + PointerID int `js:"pointerId"` + PointerType string `js:"pointerType"` +} + type PopStateEvent struct{ *BasicEvent } type ProgressEvent struct{ *BasicEvent } type RelatedEvent struct{ *BasicEvent } diff --git a/v2/events.go b/v2/events.go index ff531b7..215d32c 100644 --- a/v2/events.go +++ b/v2/events.go @@ -310,7 +310,12 @@ func (ev *MouseEvent) ModifierState(mod string) bool { type MutationEvent struct{ *BasicEvent } type OfflineAudioCompletionEvent struct{ *BasicEvent } type PageTransitionEvent struct{ *BasicEvent } + type PointerEvent struct{ *MouseEvent } + +func (ev *PointerEvent) PointerID() int { return ev.Get("pointerId").Int() } +func (ev *PointerEvent) PointerType() string { return ev.Get("pointerType").String() } + type PopStateEvent struct{ *BasicEvent } type ProgressEvent struct{ *BasicEvent } type RelatedEvent struct{ *BasicEvent } From fc652bea59afb30933a35b34063f81067642e4c0 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Tue, 8 Oct 2024 22:48:25 -0400 Subject: [PATCH 2/2] add DataTransfer.SetData See https://developer.mozilla.org/docs/Web/API/DataTransfer/setData. --- dom.go | 4 ++++ v2/dom.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/dom.go b/dom.go index 0443e0e..aac3b4c 100644 --- a/dom.go +++ b/dom.go @@ -3129,3 +3129,7 @@ type DataTransfer struct{ *js.Object } func (dt *DataTransfer) GetData(format string) string { return dt.Call("getData", format).String() } + +func (dt *DataTransfer) SetData(format, data string) { + dt.Call("setData", format, data) +} diff --git a/v2/dom.go b/v2/dom.go index deaa890..bfe5206 100644 --- a/v2/dom.go +++ b/v2/dom.go @@ -3363,3 +3363,7 @@ type DataTransfer struct{ js.Value } func (dt *DataTransfer) GetData(format string) string { return dt.Call("getData", format).String() } + +func (dt *DataTransfer) SetData(format, data string) { + dt.Call("setData", format, data) +}