Documentation
¶
Index ¶
- type VNode
- func Button(content string, attrs map[string]any, children ...*VNode) *VNode
- func Div(attrs map[string]any, children ...*VNode) *VNode
- func InputText(attrs map[string]any) *VNode
- func NewVNode(tag string, attributes map[string]any, children []*VNode, content string) *VNode
- func Paragraph(text string, attrs map[string]any) *VNode
- func Text(content string) *VNode
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 ¶
Button creates a <button> VNode with the given children and allows passing attributes.
func InputText ¶
InputText returns a VNode representing an <input type="text"> element. Optionally accepts a map of attributes (e.g., {"placeholder": "Type here"}).
func Paragraph ¶
Paragraph creates a <p> VNode with the given text as its child and allows passing attributes.
func Text ¶
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 ¶
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 ¶
GetEventCallbacks returns all stored event callbacks. This is used by WASM-only code to access the callbacks for cleanup.
func (*VNode) SetContent ¶
SetContent updates the Content field of the VNode.