vdom

package module
v0.0.0-...-075ae88 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

README

Simple virtual dom library for use with Go on WASM. More docs to come.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttrsPatch

type AttrsPatch struct {
	Add    map[string]string
	Remove []string
}

type ChildPatch

type ChildPatch struct {
	Common []Patch
	Drop   int
	Append []VNode
}

type DomNode

type DomNode struct {
	Value any
}

type Event

type Event struct {
	Value any
}

type EventHandler

type EventHandler = *func(Event) any

N.B. the pointer indirection is so these can be compared.

type EventsPatch

type EventsPatch struct {
	Add    map[string]EventHandler
	Remove []string
}

type ModifyPatch

type ModifyPatch struct {
	Attrs    AttrsPatch
	Events   EventsPatch
	Children ChildPatch
}

func (ModifyPatch) Patch

func (ModifyPatch) Patch(p, n DomNode) DomNode

type NopPatch

type NopPatch struct{}

func (NopPatch) Patch

func (NopPatch) Patch(parent, orig DomNode) DomNode

type Patch

type Patch interface {
	// Apply the patch to a DOM node (orig). The first argument
	// is the parent of the dom node being patched. The return
	// value is the new node, which may or may not be the same
	// as the old node.
	Patch(parent, orig DomNode) DomNode
}

type ReplacePatch

type ReplacePatch struct {
	Replacement VNode
}

func (ReplacePatch) Patch

func (p ReplacePatch) Patch(parent, n DomNode) DomNode

type VElem

type VElem struct {
	Tag      string
	Attrs    map[string]string
	Events   map[string]EventHandler
	Children []VNode
}

func (*VElem) Diff

func (ve *VElem) Diff(dst VNode) Patch

func (VElem) ToDomNode

func (ve VElem) ToDomNode() DomNode

type VNode

type VNode interface {
	Diff(dst VNode) Patch
	ToDomNode() DomNode
}

type VText

type VText string

func (VText) Diff

func (vt VText) Diff(dst VNode) Patch

func (VText) ToDomNode

func (vt VText) ToDomNode() DomNode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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