dom

package module
v0.0.0-...-326e720 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 3 Imported by: 1

README

dom

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

View Source
var (
	ValueOf   = js.ValueOf
	FuncOf    = js.FuncOf
	Global    = js.Global
	Undefined = js.Undefined
)

Functions

func Alert

func Alert(a ...interface{})

func Alertf

func Alertf(format string, a ...interface{})

func Append

func Append(children ...interface{})

Append adds children to default body of document.

func IsObject

func IsObject(v Value) bool

IsObject returns true if v is an object or function, or returns false.

func Prepend

func Prepend(children ...interface{})

Prepend adds children as first element in default body.

Types

type Event

type Event interface {
	Wrapper

	// Type returns event type.
	Type() string

	// Target returns who issues the event.
	Target() EventTarget

	// PreventDefault stops default behaviors.
	PreventDefault()
}

Event represents javascript event.

func EventOf

func EventOf(v Value) Event

EventOf returns event.

type EventTarget

type EventTarget interface {
	Wrapper

	// AddEventListener adds callback for event.
	AddEventListener(event string, cb Func)

	// Release frees all callbacks.
	Release()
}

EventTarget represents javascript event target.

func EventTargetOf

func EventTargetOf(v Value) EventTarget

EventTargetOf returns an EventTaget object from js.Value.

type Fragment

type Fragment interface {
	Node
}

Fragment represents DocumentFragment.

func FragmentOf

func FragmentOf(html HTML) Fragment

FragmentOf converts HTML to Fragment.

type Func

type Func = js.Func

type HTML

type HTML string

func (HTML) JSValue

func (h HTML) JSValue() Value

JSValue implements syscall/js.Wrapper

func (HTML) String

func (h HTML) String() string

type HTMLElement

type HTMLElement interface {
	Node
	fmt.Stringer

	// Tag returns tag name.
	Tag() string

	// Prop returns value of property p.
	Prop(p string) Value

	// SetProp sets property p with value v.
	SetProp(p string, x interface{}) HTMLElement

	// Attr returns value of attribute a.
	Attr(a string) string

	// SetAttr sets attribute a with value v.
	SetAttr(args string, v string) HTMLElement

	// RemoveAttr removes attribute a.
	RemoveAttr(a string) HTMLElement

	// Text returns inner text.
	Text() string

	// SetText sets inner text.
	SetText(content string) HTMLElement

	// HTML returns innner html.
	HTML() HTML

	// SetHTML sets inner html.
	SetHTML(content HTML) HTMLElement

	// Add adds class to class list.
	Add(names ...string) HTMLElement

	// Remove removes class from class list.
	Remove(names ...string) HTMLElement

	// Toggle toggle some class.
	Toggle(name string) HTMLElement

	// Replace replaces old class with new one.
	Replace(old, new string) HTMLElement

	// Contains returns true if it has the class n, or returns false.
	Contains(n string) bool

	// Val returns value of input, select and textarea element.
	Val() string

	// SetVal set value of input, select and textarea element.
	SetVal(val string) HTMLElement

	// Free deposes the element from dom tree.
	Free()

	// On adds a callback for event.
	On(event string, cb func(HTMLElement, Event)) HTMLElement
}

HTMLElement represents DOM HTMLElement.

func CreateElement

func CreateElement(tag string) HTMLElement

CreateElement returns a html element with html tag.

func HTMLElementOf

func HTMLElementOf(v Value) HTMLElement

func Query

func Query(selectors string) HTMLElement

type HTMLElements

type HTMLElements []HTMLElement

func QueryAll

func QueryAll(selectors string) HTMLElements

func (HTMLElements) Foreach

func (elems HTMLElements) Foreach(fn func(int, HTMLElement))

type Node

type Node interface {
	EventTarget
	Query(selectors string) HTMLElement
	QueryAll(selectors string) HTMLElements

	Append(children ...interface{}) Node
	Prepend(children ...interface{}) Node
	ReplaceChildren(children ...interface{}) Node
	Empty() Node

	Call(m string, args ...interface{}) Value
}

func NodeOf

func NodeOf(v Value) Node

type Type

type Type = js.Type

type Value

type Value = js.Value

func Call

func Call(m string, args ...interface{}) Value

type Wrapper

type Wrapper = js.Wrapper

Jump to

Keyboard shortcuts

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