vdom

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VNode

type VNode struct {
	Tag          string         // The HTML tag name
	Attributes   map[string]any // The attributes of the node
	Children     []*VNode       // The child nodes
	Content      string         // The content of the node
	OnClick      func()         // Optional click event handler
	Key          any            // Optional key for list reconciliation (used in {@for} loops)
	ComponentKey string         // Key for component-level reconciliation (used in router navigation)
	// contains filtered or unexported fields
}

VNode represents a virtual DOM node. This core file has NO build tags, making it available to both WASM and native test builds.

func Button

func Button(content string, attrs map[string]any, children ...*VNode) *VNode

Button creates a <button> VNode with the given children and allows passing attributes.

func Div

func Div(attrs map[string]any, children ...*VNode) *VNode

Div creates a <div> VNode with the given children and allows passing attributes.

func InputText

func InputText(attrs map[string]any) *VNode

InputText returns a VNode representing an <input type="text"> element. Optionally accepts a map of attributes (e.g., {"placeholder": "Type here"}).

func NewVNode

func NewVNode(tag string, attributes map[string]any, children []*VNode, content string) *VNode

NewVNode creates a new VNode.

func Paragraph

func Paragraph(text string, attrs map[string]any) *VNode

Paragraph creates a <p> VNode with the given text as its child and allows passing attributes.

func Text

func Text(content string) *VNode

Text creates a pure text node VNode (no HTML element wrapper). This uses the special "#text" tag which renders as document.createTextNode() in the browser. Use this for creating text content without any surrounding HTML element.

func (*VNode) AddEventCallback

func (v *VNode) AddEventCallback(cb any)

AddEventCallback stores a js.Func (as interface{}) for later cleanup. This is called from WASM-only code in render.go.

func (*VNode) ClearEventCallbacks

func (v *VNode) ClearEventCallbacks()

ClearEventCallbacks clears the event callbacks slice without releasing them. The actual release is done in WASM-only code in render.go.

func (*VNode) GetEventCallbacks

func (v *VNode) GetEventCallbacks() []any

GetEventCallbacks returns all stored event callbacks. This is used by WASM-only code to access the callbacks for cleanup.

func (*VNode) SetContent

func (v *VNode) SetContent(content string)

SetContent updates the Content field of the VNode.

Jump to

Keyboard shortcuts

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