Documentation
¶
Overview ¶
Package dom provides APIs for interacting with the DOM.
Index ¶
- Variables
- func DefaultQueryString() string
- func ExpandArgs(args []js.Value, target ...*js.Value)
- func FromJSON(s string) js.Value
- func Log(format string, objs ...interface{})
- func LogDebug(format string, objs ...interface{})
- func LogError(format string, objs ...interface{})
- func ObjectKeys(val js.Value) ([]string, error)
- func SetTimeout(timeout time.Duration, callback func())
- func SingleArg(args []js.Value) js.Value
- func ToJSON(val js.Value) string
- type DOM
- func (d *DOM) AppendChild(parent, child js.Value, populate func(child js.Value))
- func (d *DOM) Close(o js.Value)
- func (d *DOM) DoClick(o js.Value)
- func (d *DOM) GetElement(id string) js.Value
- func (d *DOM) GetElementsByTag(tag string) []js.Value
- func (d *DOM) NewElement(tag string) js.Value
- func (d *DOM) NewText(text string) js.Value
- func (d *DOM) OnClick(o js.Value, callback func(evt Event))
- func (d *DOM) OnDOMContentLoaded(callback func())
- func (d *DOM) RemoveChildren(p js.Value)
- func (d *DOM) RemoveEventListeners(o js.Value) js.Value
- func (d *DOM) SetValue(o js.Value, value string)
- func (d *DOM) ShowModal(o js.Value)
- func (d *DOM) TextContent(o js.Value) string
- func (d *DOM) Value(o js.Value) string
- type Event
- type URLSearchParams
Constants ¶
This section is empty.
Variables ¶
var ( // Doc is the default 'document' object. This should be used for regular // code. See NewDocForTesting() for a Document object that can be used in // unit tests. Doc = js.Global().Get("document") // Console is the default 'console' object for the browser. Console = js.Global().Get("console") // Object refers to Javascript's Object class. Object = js.Global().Get("Object") // JSON refers to Javascript's JSON class. JSON = js.Global().Get("JSON") )
Functions ¶
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 ExpandArgs ¶ added in v0.0.20
ExpandArgs unpacks function arguments to target values.
func Log ¶ added in v0.0.20
func Log(format string, objs ...interface{})
Log logs general information to the Javascript Console.
func LogDebug ¶ added in v0.0.20
func LogDebug(format string, objs ...interface{})
LogDebug logs a debug message to the Javascript Console.
func LogError ¶ added in v0.0.20
func LogError(format string, objs ...interface{})
LogError logs an error to the Javascript Console.
func ObjectKeys ¶ added in v0.0.20
ObjectKeys returns the keys for a given object.
func SetTimeout ¶ added in v0.0.20
SetTimeout registers a callback to be invoked when the timeout has expired.
Types ¶
type DOM ¶
type DOM struct {
// contains filtered or unexported fields
}
DOM provides an API for interacting with the DOM for a Document.
func (*DOM) AppendChild ¶
AppendChild adds the child object. If non-nil, the populate() function is invoked on the child to initialize it.
func (*DOM) DoClick ¶
DoClick simulates a click. Any callback registered by OnClick() will be invoked.
func (*DOM) GetElement ¶
GetElement returns the element with the specified ID.
func (*DOM) GetElementsByTag ¶ added in v0.0.12
GetElementsByTag returns the elements with the speciied tag.
func (*DOM) NewElement ¶
NewElement returns a new element with the specified tag (e.g., 'tr', 'td').
func (*DOM) OnClick ¶
OnClick registers a callback to be invoked when the specified object is clicked.
func (*DOM) OnDOMContentLoaded ¶
func (d *DOM) OnDOMContentLoaded(callback func())
OnDOMContentLoaded registers a callback to be invoked when the DOM has finished loading.
func (*DOM) RemoveChildren ¶
RemoveChildren removes all children of the specified node.
func (*DOM) RemoveEventListeners ¶ added in v0.0.8
RemoveEventListeners removes all event listeners from an object and its children. This is accomplished by cloning the object, which has the side effect of *not* cloning the event listeners. The newly-created object is returned.
func (*DOM) TextContent ¶
TextContent returns the text content of the specified object (and its children).
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.