dom

package
v0.0.28 Latest Latest
Warning

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

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

Documentation

Rendered for js/wasm

Overview

Package dom provides APIs for interacting with the DOM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendChild added in v0.0.23

func AppendChild(parent, child js.Value, populate func(child js.Value))

AppendChild adds the child object. If non-nil, the populate() function is invoked on the child to initialize it.

func DefaultQueryString added in v0.0.12

func DefaultQueryString() string

DefaultQueryString returns the query string used to request the current document. This is likely not available during unit tests, but is available in normal operation.

func DoClick added in v0.0.23

func DoClick(o js.Value)

DoClick simulates a click. Any callback registered by OnClick() will be invoked.

func ID added in v0.0.23

func ID(o js.Value) string

ID returns the element ID of an object as a string.

func OnClick added in v0.0.23

func OnClick(o js.Value, callback func(ctx jsutil.AsyncContext, evt Event)) jsutil.CleanupFunc

OnClick registers a callback to be invoked when the specified object is clicked.

func OnSubmit added in v0.0.23

func OnSubmit(o js.Value, callback func(ctx jsutil.AsyncContext, evt Event)) jsutil.CleanupFunc

OnSubmit registers a callback to be invoked when the specified form is submitted.

func RemoveChildren added in v0.0.23

func RemoveChildren(p js.Value)

RemoveChildren removes all children of the specified node.

func SetValue added in v0.0.23

func SetValue(o js.Value, value string)

SetValue sets the of the object.

func TextContent added in v0.0.23

func TextContent(o js.Value) string

TextContent returns the text content of the specified object (and its children).

func Value added in v0.0.23

func Value(o js.Value) string

Value returns the value of an object as a string.

Types

type Dialog added in v0.0.23

type Dialog struct {
	// contains filtered or unexported fields
}

Dialog represents an HTML dialog.

func NewDialog added in v0.0.23

func NewDialog(dialog js.Value) *Dialog

NewDialog returns a dialog wrapping the specified element.

func (*Dialog) Close added in v0.0.23

func (d *Dialog) Close()

Close closes the dialog.

func (*Dialog) OnClose added in v0.0.23

func (d *Dialog) OnClose(callback func(ctx jsutil.AsyncContext, evt Event)) jsutil.CleanupFunc

OnClose registers the specified callback to be invoked when the dialog is closed. The returned function must be invoked to cleanup when it is no longer needed.

func (*Dialog) ShowModal added in v0.0.23

func (d *Dialog) ShowModal()

ShowModal shows the dialog as a modal dialog.

type Doc

type Doc struct {
	// contains filtered or unexported fields
}

Doc provides an API for interacting with the DOM for a Document.

func New

func New(doc js.Value) *Doc

New returns a Doc instance for interacting with the specified Document object.

func (*Doc) GetElement added in v0.0.23

func (d *Doc) GetElement(id string) js.Value

GetElement returns the element with the specified ID.

func (*Doc) GetElementsByTag added in v0.0.23

func (d *Doc) GetElementsByTag(tag string) []js.Value

GetElementsByTag returns the elements with the speciied tag.

func (*Doc) NewElement added in v0.0.23

func (d *Doc) NewElement(tag string) js.Value

NewElement returns a new element with the specified tag (e.g., 'tr', 'td').

func (*Doc) NewText added in v0.0.23

func (d *Doc) NewText(text string) js.Value

NewText returns a new text element with the specified text.

func (*Doc) OnDOMContentLoaded added in v0.0.23

func (d *Doc) OnDOMContentLoaded(callback func(ctx jsutil.AsyncContext)) jsutil.CleanupFunc

OnDOMContentLoaded registers a callback to be invoked when the DOM has finished loading.

type Event added in v0.0.20

type Event struct {
	js.Value
}

Event provides an API for interacting with events.

type URLSearchParams added in v0.0.12

type URLSearchParams struct {
	// contains filtered or unexported fields
}

URLSearchParams is a thin wrapper around the URLSearchParams API. See https://url.spec.whatwg.org/#urlsearchparams.

func NewURLSearchParams added in v0.0.12

func NewURLSearchParams(queryString string) *URLSearchParams

NewURLSearchParams returns a URLSearchParams for the specified query string.

func (*URLSearchParams) Has added in v0.0.12

func (u *URLSearchParams) Has(param string) bool

Has indicates if the query string contains the specified parameter.

Directories

Path Synopsis
Package testing provides utilities for using the DOM in unit tests.
Package testing provides utilities for using the DOM in unit tests.

Jump to

Keyboard shortcuts

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