package
0.0.0-20180612134603-5a689ece0d3e
Repository: https://github.com/mjkwoolnough/gopherjs.git
Documentation: pkg.go.dev

# README

mutation

-- import "github.com/MJKWoolnough/gopherjs/mutation"

Package mutation provides a wrapper for the MutationObserver API

Usage

type Observer

type Observer struct {
	*js.Object
}

Observer wraps a MutationObserver javascript object

func New

func New(f func([]*Record, *Observer)) *Observer

New creates a new wrapper around MutationObserver, which is created with the given callback

func (*Observer) Disconnect

func (m *Observer) Disconnect()

Disconnect stops the observer from receiving events

func (*Observer) Observe

func (m *Observer) Observe(n dom.Node, i ObserverInit)

Observe registers a DOM Node to receive events for

func (*Observer) TakeRecords

func (m *Observer) TakeRecords() []*Record

TakeRecords empties the record queue, returning what was in it

type ObserverInit

type ObserverInit struct {
	ChildList             bool
	Attributes            bool
	CharacterData         bool
	Subtree               bool
	AttributeOldValue     bool
	CharacterDataOldValue bool
	AttributeFilter       []string
}

ObserverInit contains the options for observing a Node

type Record

type Record struct {
	*js.Object
	Type               string `js:"type"`
	AttributeName      string `js:"attributeName"`
	AttributeNamespace string `js:"attributeNamespace"`
	OldValue           string `js:"oldValue"`
}

Record is a wrapper around a MutationRecord js type

func (*Record) AddedNodes

func (r *Record) AddedNodes() []dom.Node

AddedNodes returns any nodes that were added

func (*Record) NextSibling

func (r *Record) NextSibling() dom.Node

NextSibling returns the next sibling to any added or removed nodes

func (*Record) PreviousSibling

func (r *Record) PreviousSibling() dom.Node

PreviousSibling returns the previous sibling to any added or removed nodes

func (*Record) RemovedNodes

func (r *Record) RemovedNodes() []dom.Node

RemovedNodes returns any nodes that were added

func (*Record) Target

func (r *Record) Target() dom.Node

Target returns the node associated with the record

# Functions

New creates a new wrapper around MutationObserver, which is created with the given callback.

# Structs

Observer wraps a MutationObserver javascript object.
ObserverInit contains the options for observing a Node.
Record is a wrapper around a MutationRecord js type.