mutation

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributeFilter

func AttributeFilter(val ...string) func(*Options)

func AttributeOldValue

func AttributeOldValue(o *Options)

func Attributes

func Attributes(o *Options)

func CharacterData

func CharacterData(o *Options)

func CharacterDataOldValue

func CharacterDataOldValue(o *Options)

func ChildList

func ChildList(o *Options)

func Subtree

func Subtree(o *Options)

Types

type Callback

type Callback interface {
	HandleMutation([]Record, *Observer)
}

type CallbackFunc

type CallbackFunc func([]Record, *Observer)

func (CallbackFunc) HandleMutation

func (f CallbackFunc) HandleMutation(r []Record, o *Observer)

type MicrotaskQueuer added in v0.11.3

type MicrotaskQueuer interface {
	QueueMicrotask(clock.TaskCallback)
}

type ObserveOption added in v0.6.0

type ObserveOption = func(*Options)

type Observer

type Observer struct {
	Flushers MicrotaskQueuer
	Callback Callback
	// contains filtered or unexported fields
}

Observer implements behaviour of the MutationObserver, allowing client code to react to changes to the DOM. Mutation events are not published immediately; but before control returns to the event loop, (i.e. if an event hander generates two mutation events, an observer will not receive any events before the function has finished executing). The records can be pulled from the Observer.TakeRecords function.

Client code must first call [MutationObserver.Observe], specifying what to listen for.

The Observer must be initialized with both a MicrotaskQueuer, allowing it to register to receive notifications; and a Callback.

func NewObserver

func NewObserver(f MicrotaskQueuer, cb Callback) *Observer

NewObserver creates a new observer registering with the MicrotaskQueuer f and the callback cb. NewObserver doesn't do anything except setting exported fields. The function panics if either f or cb are nil.

func (*Observer) Disconnect

func (o *Observer) Disconnect()

func (*Observer) Observe

func (o *Observer) Observe(node dom.Node, options ...func(*Options)) error

Start observing for changes for a specific dom node.

Panics if the observer does not have a handler.

func (*Observer) Process

func (o *Observer) Process(e dom.ChangeEvent)

func (*Observer) TakeRecords

func (o *Observer) TakeRecords() (res []Record)

type Record

type RecordCallbackFunc

type RecordCallbackFunc func([]Record)

func (RecordCallbackFunc) HandleMutation

func (f RecordCallbackFunc) HandleMutation(r []Record, _ *Observer)

Jump to

Keyboard shortcuts

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