dom

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddEventListenerOptions

type AddEventListenerOptions struct {
	EventListenerOptions
	Passive bool
	Once    bool
	Signal  context.Context
}

type Event

type Event interface {
	// Type returns the type of event, e.g. "click", "hashchange", or "submit".
	Type() string
	// Target returns the object to which event is dispatched (its target).
	Target() EventTarget
	// CurrentTarget returns the object whose event listener’s callback is currently being invoked.
	CurrentTarget() EventTarget
	// EventPhase returns the invocation target objects of event’s path.
	EventPhase() EventPhase
	// TimeStamp returns the event’s timestamp as the number of milliseconds measured relative to the occurrence.
	TimeStamp() int64
	// Bubbles returns true or false depending on how event was initialized.
	Bubbles() bool
	// Cancelable returns true or false depending on how event was initialized.
	Cancelable() bool
	// DefaultPrevented returns true if preventDefault() was invoked successfully to indicate cancelation; otherwise false.
	DefaultPrevented() bool

	// StopPropagation prevents event from reaching any objects other than the current object.
	StopPropagation()
	// StopImmediatePropagation prevents event from reaching any registered event listeners after
	// the current one finishes running.
	StopImmediatePropagation()
	// PreventDefault If invoked when the cancelable attribute value is true,
	// and while executing a listener for the event with passive set to false
	PreventDefault()
	// contains filtered or unexported methods
}

Event defines the DOM Event interface https://dom.spec.whatwg.org/#event

func NewEvent

func NewEvent(typ string) Event

NewEvent creates a new Event instance

type EventListener

type EventListener interface {
	HandleEvent(event Event) error
	Equals(e EventListener) bool
	Options() AddEventListenerOptions
}

func NewEventListener

func NewEventListener(fn func(Event) error, opts AddEventListenerOptions) EventListener

NewEventListener creates a new EventListener

type EventListenerOptions

type EventListenerOptions struct {
	Capture bool
}

type EventPhase

type EventPhase int
const (
	EventPhaseNone EventPhase = iota
	EventPhaseCapturing
	EventPhaseAtTarget
	EventPhaseBubbling
)

type EventTarget

type EventTarget interface {
	// AddEventListener registers an event handler of a specific event type on the EventTarget
	AddEventListener(typ string, listener EventListener)
	// RemoveEventListener removes an event listener from the EventTarget
	RemoveEventListener(typ string, listener EventListener)
	// DispatchEvent dispatches an event to this EventTarget
	DispatchEvent(event Event) bool
	// Listeners returns all event listeners for a specific event type
	Listeners(typ string) []EventListener
	// contains filtered or unexported methods
}

EventTarget defines the DOM EventTarget interface https://dom.spec.whatwg.org/#interface-eventtarget

func NewEventTarget

func NewEventTarget() EventTarget

NewEventTarget creates a new EventTarget instance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL