mutation

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 3 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 Flusher added in v0.6.0

type Flusher interface {
	Flush()
}

type FlusherSet added in v0.6.0

type FlusherSet struct {
	// contains filtered or unexported fields
}

func (*FlusherSet) AddFlusher added in v0.6.0

func (r *FlusherSet) AddFlusher(f Flusher)

func (*FlusherSet) Flush added in v0.6.0

func (r *FlusherSet) Flush()

func (*FlusherSet) RemoveFlusher added in v0.6.0

func (r *FlusherSet) RemoveFlusher(f Flusher)

type Flushers added in v0.6.0

type Flushers interface {
	AddFlusher(Flusher)
	RemoveFlusher(Flusher)
}

type ObserveOption added in v0.6.0

type ObserveOption = func(*Options)

type Observer

type Observer struct {
	Flushers Flushers
	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 Flushers, allowing it to register to receive notifications; and a Callback.

func NewObserver

func NewObserver(f Flushers, cb Callback) *Observer

NewObserver creates a new observer registering with the Flushers 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) Flush

func (o *Observer) Flush()

Flush sends recorded events to the registered event handler. You generally don't need to call flush, as events should be pushed when returning to the "event loop".

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