dom

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package dom provides APIs for interacting with the DOM.

Index

Constants

This section is empty.

Variables

View Source
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

This section is empty.

Types

type DOM

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

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

func New

func New(doc *js.Object) *DOM

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

func (*DOM) AppendChild

func (d *DOM) AppendChild(parent, child *js.Object, populate func(child *js.Object))

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

func (*DOM) Close

func (d *DOM) Close(o *js.Object)

Close closes the specified dialog.

func (*DOM) DoClick

func (d *DOM) DoClick(o *js.Object)

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

func (d *DOM) GetElement(id string) *js.Object

GetElement returns the element with the specified ID.

func (*DOM) NewElement

func (d *DOM) NewElement(tag string) *js.Object

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

func (*DOM) NewText

func (d *DOM) NewText(text string) *js.Object

NewText returns a new text element with the specified text.

func (*DOM) OnClick

func (d *DOM) OnClick(o *js.Object, callback func())

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

func (d *DOM) RemoveChildren(p *js.Object)

RemoveChildren removes all children of the specified node.

func (*DOM) RemoveEventListeners added in v0.0.8

func (d *DOM) RemoveEventListeners(o *js.Object) *js.Object

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) SetValue

func (d *DOM) SetValue(o *js.Object, value string)

SetValue sets the of the object.

func (*DOM) ShowModal

func (d *DOM) ShowModal(o *js.Object)

ShowModal shows the specified dialog as a modal dialog.

func (*DOM) TextContent

func (d *DOM) TextContent(o *js.Object) string

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

func (*DOM) Value

func (d *DOM) Value(o *js.Object) string

Value returns the value of an object as a string.

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