dom

package
v0.0.0-...-9038b1f Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(elem Element, mods ...Modifier)

Types

type ChildHolder

type ChildHolder struct {
	Element Element
	// contains filtered or unexported fields
}

func Button

func Button(mods ...Modifier) ChildHolder

func Circle

func Circle(mods ...Modifier) ChildHolder

func Div

func Div(mods ...Modifier) ChildHolder

func Elem

func Elem(name string, mods ...Modifier) ChildHolder

func I

func I(mods ...Modifier) ChildHolder

func Input

func Input(mods ...Modifier) ChildHolder

func P

func P(mods ...Modifier) ChildHolder

func Span

func Span(mods ...Modifier) ChildHolder

func Svg

func Svg(mods ...Modifier) ChildHolder

func (ChildHolder) Apply

func (f ChildHolder) Apply(e Element)

func (ChildHolder) Build

func (f ChildHolder) Build(e Element) Element

func (ChildHolder) Self

func (f ChildHolder) Self(e *Element) ChildHolder

type Document

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

The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree. The DOM tree includes elements such as <body> and <table>, among many others. It provides functionality globally to the document, like how to obtain the page's URL and create new elements in the document. The Document interface describes the common properties and methods for any kind of document. Depending on the document's type (e.g. HTML, XML, SVG, …), a larger API is available: HTML documents, served with the "text/html" content type, also implement the HTMLDocument interface, whereas XML and SVG documents implement the XMLDocument interface.

func (Document) AppendChild

func (n Document) AppendChild(aChild Node) Node

The absNode.appendChild() method adds a node to the end of the list of children of a specified parent node. If the given child is a reference to an existing node in the document, appendChild() moves it from its current position to the new position (there is no requirement to remove the node from its parent node before appending it to some other node).

This means that a node can't be in two points of the document simultaneously. So if the node already has a parent, the node is first removed, then appended at the new position. The absNode.cloneNode() method can be used to make a copy of the node before appending it under the new parent. Note that the copies made with cloneNode will not be automatically kept in sync.

If the given child is a DocumentFragment, the entire contents of the DocumentFragment are moved into the child list of the specified parent node.

func (Document) Body

func (d Document) Body() Element

func (Document) Clear

func (n Document) Clear()

func (Document) CreateElement

func (d Document) CreateElement(name string) Element

In an HTML document, the document.createElement() method creates the HTML element specified by tagName, or an HTMLUnknownElement if tagName isn't recognized.

func (Document) CreateElementNS

func (d Document) CreateElementNS(ns string, name string) Element

In an HTML document, the document.createElement() method creates the HTML element specified by tagName, or an HTMLUnknownElement if tagName isn't recognized.

func (Document) DocumentElement

func (d Document) DocumentElement() Element

func (Document) GetElementById

func (d Document) GetElementById(id string) Element

The Document method getElementById() returns an Element object representing the element whose id property matches the specified string. Since element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly.

If you need to get access to an element which doesn't have an ID, you can use querySelector() to find the element using any selector.

func (Document) InnerHTML

func (n Document) InnerHTML() string

The Element property innerHTML gets or sets the HTML or XML markup contained within the element.

Note: If a <div>, <span>, or <noembed> node has a child text node that includes the characters (&), (<), or (>), innerHTML returns these characters as the HTML entities "&amp;", "&lt;" and "&gt;" respectively. Use Node.textContent to get a raw copy of these text nodes' contents. To insert the HTML into the document rather than replace the contents of an element, use the method insertAdjacentHTML().

func (Document) InsertBefore

func (n Document) InsertBefore(newNode, refNode Node) Node

func (Document) NextSibling

func (n Document) NextSibling() Node

func (Document) RemoveChild

func (n Document) RemoveChild(aChild Node) Node

func (Document) SetInnerHTML

func (n Document) SetInnerHTML(v string)

The Element property innerHTML gets or sets the HTML or XML markup contained within the element.

Note: If a <div>, <span>, or <noembed> node has a child text node that includes the characters (&), (<), or (>), innerHTML returns these characters as the HTML entities "&amp;", "&lt;" and "&gt;" respectively. Use Node.textContent to get a raw copy of these text nodes' contents. To insert the HTML into the document rather than replace the contents of an element, use the method insertAdjacentHTML().

func (Document) SetInnerText

func (n Document) SetInnerText(v string) absNode

func (Document) SetTextContent

func (n Document) SetTextContent(v string)

The SetTextContent property of the absNode interface represents the text content of the node and its descendants.

func (Document) Style

func (n Document) Style() Style

func (Document) TextContent

func (n Document) TextContent() string

The TextContent property of the absNode interface represents the text content of the node and its descendants.

func (Document) Unwrap

func (n Document) Unwrap() js.Value

type Element

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

Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element. For example, the HTMLElement interface is the base interface for HTML elements, while the SVGElement interface is the basis for all SVG elements. Most functionality is specified further down the class hierarchy.&

Languages outside the realm of the Web platform, like XUL through the XULElement interface, also implement Element.

func NewElement

func NewElement(v js.Value) Element

func (Element) AddClass

func (s Element) AddClass(v string) Element

func (Element) AddEventListener

func (t Element) AddEventListener(typ string, listener func(this js.Value, args []js.Value) interface{}, once bool) Func

func (Element) AppendChild

func (n Element) AppendChild(aChild Node) Node

The absNode.appendChild() method adds a node to the end of the list of children of a specified parent node. If the given child is a reference to an existing node in the document, appendChild() moves it from its current position to the new position (there is no requirement to remove the node from its parent node before appending it to some other node).

This means that a node can't be in two points of the document simultaneously. So if the node already has a parent, the node is first removed, then appended at the new position. The absNode.cloneNode() method can be used to make a copy of the node before appending it under the new parent. Note that the copies made with cloneNode will not be automatically kept in sync.

If the given child is a DocumentFragment, the entire contents of the DocumentFragment are moved into the child list of the specified parent node.

func (Element) Clear

func (n Element) Clear()

func (Element) FirstChild

func (s Element) FirstChild() Element

func (Element) GetAttr

func (s Element) GetAttr(key interface{}) js.Value

func (Element) HasClass

func (s Element) HasClass(v string) bool

func (Element) Id

func (s Element) Id() string

func (Element) InnerHTML

func (n Element) InnerHTML() string

The Element property innerHTML gets or sets the HTML or XML markup contained within the element.

Note: If a <div>, <span>, or <noembed> node has a child text node that includes the characters (&), (<), or (>), innerHTML returns these characters as the HTML entities "&amp;", "&lt;" and "&gt;" respectively. Use Node.textContent to get a raw copy of these text nodes' contents. To insert the HTML into the document rather than replace the contents of an element, use the method insertAdjacentHTML().

func (Element) InsertBefore

func (n Element) InsertBefore(newNode, refNode Node) Node

func (Element) IsValid

func (s Element) IsValid() bool

func (Element) NextSibling

func (n Element) NextSibling() Node

func (Element) RemoveChild

func (n Element) RemoveChild(aChild Node) Node

func (Element) RemoveClass

func (s Element) RemoveClass(v string) Element

func (Element) SetAriaHidden

func (s Element) SetAriaHidden(b bool) Element

func (Element) SetAriaLabel

func (s Element) SetAriaLabel(l string) Element

func (Element) SetAriaOrientation

func (s Element) SetAriaOrientation(o string) Element

func (Element) SetAttr

func (s Element) SetAttr(key, val interface{}) Element

func (Element) SetAttrNS

func (s Element) SetAttrNS(ns string, key, val string) Element

func (Element) SetClassName

func (s Element) SetClassName(str string) Element

func (Element) SetDisabled

func (s Element) SetDisabled(b bool) Element

func (Element) SetFor

func (s Element) SetFor(id string) Element

func (Element) SetHref

func (s Element) SetHref(v string) Element

func (Element) SetId

func (s Element) SetId(id string) Element

func (Element) SetInnerHTML

func (n Element) SetInnerHTML(v string)

The Element property innerHTML gets or sets the HTML or XML markup contained within the element.

Note: If a <div>, <span>, or <noembed> node has a child text node that includes the characters (&), (<), or (>), innerHTML returns these characters as the HTML entities "&amp;", "&lt;" and "&gt;" respectively. Use Node.textContent to get a raw copy of these text nodes' contents. To insert the HTML into the document rather than replace the contents of an element, use the method insertAdjacentHTML().

func (Element) SetInnerText

func (s Element) SetInnerText(str string) Element

func (Element) SetRole

func (s Element) SetRole(r string) Element

func (Element) SetScope

func (s Element) SetScope(r string) Element

func (Element) SetTabIndex

func (s Element) SetTabIndex(i int) Element

func (Element) SetText

func (s Element) SetText(v string) Element

func (Element) SetTextContent

func (n Element) SetTextContent(v string)

The SetTextContent property of the absNode interface represents the text content of the node and its descendants.

func (Element) SetType

func (s Element) SetType(t string) Element

func (Element) Style

func (n Element) Style() Style

func (Element) TextContent

func (n Element) TextContent() string

The TextContent property of the absNode interface represents the text content of the node and its descendants.

func (Element) Unwrap

func (n Element) Unwrap() js.Value

type EventTarget

type EventTarget interface {

	// The EventTarget method addEventListener() sets up a function that will be called whenever the specified event is delivered to the target. Common targets are Element, Document, and Window, but the target may be any object that supports events (such as XMLHttpRequest).
	//
	//addEventListener() works by adding a function or an object that implements EventListener to the list of event listeners for the specified event type on the EventTarget on which it's called.
	AddEventListener(typ string, listener func())
}

EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.

Element, Document, and Window are the most common event targets, but other objects can be event targets too, for example XMLHttpRequest, AudioNode, AudioContext, and others.

Many event targets (including elements, documents, and windows) also support setting event handlers via onevent properties and attributes.

type Func

type Func struct {
	js.Func
	// contains filtered or unexported fields
}

func (Func) Release

func (f Func) Release()

type Location

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

The Location interface represents the location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the Document and Window interface have such a linked Location, accessible via Document.location and Window.location respectively.

func (Location) Hash

func (l Location) Hash() string

Is a DOMString containing a '#' followed by the fragment identifier of the URL.

type Modifier

type Modifier interface {
	Apply(e Element)
}

func AriaLabelledby

func AriaLabelledby(label string) Modifier

func Class

func Class(c ...string) Modifier

func Cx

func Cx(v string) Modifier

func Cy

func Cy(v string) Modifier

func Fill

func Fill(v string) Modifier

func Id

func Id(id string) Modifier

func R

func R(v string) Modifier

func Role

func Role(r string) Modifier

func StrokeMiterlimit

func StrokeMiterlimit(v string) Modifier

func StrokeWidth

func StrokeWidth(v string) Modifier

func TextContent

func TextContent(r string) Modifier

func Type

func Type(v string) Modifier

func ViewBox

func ViewBox(v string) Modifier

type Node

type Node interface {
	TextContent() string
	SetTextContent(v string)
	AppendChild(aChild Node) Node
	Unwrap() js.Value
}

Node is an interface from which various types of DOM API objects inherit. This allows these types to be treated similarly; for example, inheriting the same set of methods or being tested in the same way.

All of the following interfaces inherit the absNode interface's methods and properties: Document, Element, Attr, CharacterData (which Text, Comment, and CDATASection inherit), ProcessingInstruction, DocumentFragment, DocumentType, Notation, Entity, EntityReference

These interfaces may return null in certain cases where the methods and properties are not relevant. They may throw an exception — for example when adding children to a node type for which no children can exist.

type Style

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

func (Style) Delete

func (s Style) Delete(k string)

func (Style) Set

func (s Style) Set(k, v string)

func (Style) SetBackgroundColor

func (s Style) SetBackgroundColor(v string)

func (Style) SetColor

func (s Style) SetColor(v string)

func (Style) SetMargin

func (s Style) SetMargin(v string)

func (Style) SetMarginBottom

func (s Style) SetMarginBottom(v string)

func (Style) SetMarginLeft

func (s Style) SetMarginLeft(v string)

func (Style) SetMarginRight

func (s Style) SetMarginRight(v string)

func (Style) SetMarginTop

func (s Style) SetMarginTop(v string)

func (Style) SetPadding

func (s Style) SetPadding(v string)

func (Style) SetPaddingBottom

func (s Style) SetPaddingBottom(v string)

func (Style) SetPaddingLeft

func (s Style) SetPaddingLeft(v string)

func (Style) SetPaddingRight

func (s Style) SetPaddingRight(v string)

func (Style) SetPaddingTop

func (s Style) SetPaddingTop(v string)

func (Style) SetProperty

func (s Style) SetProperty(k, v string)

func (Style) Unwrap

func (s Style) Unwrap() js.Value

func (Style) Update

func (s Style) Update(k, v string)

Jump to

Keyboard shortcuts

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