Documentation ¶
Overview ¶
Package dom provides APIs for interacting with the DOM.
Index ¶
- Variables
- func DefaultQueryString() string
- type DOM
- func (d *DOM) AppendChild(parent, child *js.Object, populate func(child *js.Object))
- func (d *DOM) Close(o *js.Object)
- func (d *DOM) DoClick(o *js.Object)
- func (d *DOM) DoDOMContentLoaded()
- func (d *DOM) GetElement(id string) *js.Object
- func (d *DOM) GetElementsByTag(tag string) []*js.Object
- func (d *DOM) NewElement(tag string) *js.Object
- func (d *DOM) NewText(text string) *js.Object
- func (d *DOM) OnClick(o *js.Object, callback func())
- func (d *DOM) OnDOMContentLoaded(callback func())
- func (d *DOM) RemoveChildren(p *js.Object)
- func (d *DOM) RemoveEventListeners(o *js.Object) *js.Object
- func (d *DOM) SetValue(o *js.Object, value string)
- func (d *DOM) ShowModal(o *js.Object)
- func (d *DOM) TextContent(o *js.Object) string
- func (d *DOM) Value(o *js.Object) string
- 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") )
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.
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) DoDOMContentLoaded ¶
func (d *DOM) DoDOMContentLoaded()
DoDOMContentLoaded simulates the DOMContentLoaded event. Any callback registered by OnDOMContentLoaded() 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.