dom

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

Go DOM binding (and more) for WebAssembly

This library provides a Go API for different Web APIs for WebAssembly target.

It's in an active development, but an API will be carefully versioned to avoid breaking users. Use Go dependency management tools to lock a specific version.

More information about Go's WebAssembly support can be found on Go's WebAssembly wiki page.

Features:

  • Better JS API (wrappers for syscall/js)
  • Basic DOM manipulation, styles, events
  • Input elements
  • SVG elements and transforms
  • LocalStorage and SessionStorage
  • Extension APIs (tested on Chrome):
    • Native Messaging
    • Bookmarks
    • Tabs
  • net-like library for WebSockets
    • Tested with gRPC
  • wasm-server for fast prototyping

Quickstart

Pull the library and install wasm-server (optional):

go get -u github.com/itskass/dom
go install github.com/itskass/dom/cmd/wasm-server

Run an example app:

cd $GOPATH/src/github.com/itskass/dom
wasm-server

Check result: http://localhost:8080/

The source code is recompiled on each page refresh, so feel free to experiment!

Similar Projects

Editor Configuration

If you are using Visual Studio Code, you can use workspace settings to configure the environment variables for the go tools.

Your settings.json file should look something like this:

{
    "go.toolsEnvVars": { "GOARCH": "wasm", "GOOS": "js" }
}

Documentation

Index

Constants

View Source
const (
	MouseLeft = MouseButton(0)
)

Variables

View Source
var (
	Doc  = GetDocument()
	Body = getFirstWithTag("body")
	Head = getFirstWithTag("head")
)

Functions

func ConsoleLog

func ConsoleLog(args ...interface{})

func Loop

func Loop()

func RegisterEventType

func RegisterEventType(typ string, fnc EventConstructor)

Types

type AttachShadowOpts added in v0.4.0

type AttachShadowOpts struct {
	Open           bool
	DeligatesFocus bool
}

type Auto

type Auto struct{}

func (Auto) String

func (Auto) String() string

type BaseEvent

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

func (*BaseEvent) Bubbles

func (e *BaseEvent) Bubbles() bool

func (*BaseEvent) Cancelable

func (e *BaseEvent) Cancelable() bool

func (*BaseEvent) Composed

func (e *BaseEvent) Composed() bool

func (*BaseEvent) CurrentTarget

func (e *BaseEvent) CurrentTarget() *Element

func (*BaseEvent) DefaultPrevented

func (e *BaseEvent) DefaultPrevented() bool

func (*BaseEvent) IsTrusted

func (e *BaseEvent) IsTrusted() bool

func (*BaseEvent) JSValue added in v0.4.0

func (e *BaseEvent) JSValue() js.Ref

func (*BaseEvent) Path

func (e *BaseEvent) Path() NodeList

func (*BaseEvent) PreventDefault added in v0.2.1

func (e *BaseEvent) PreventDefault()

func (*BaseEvent) StopImmediatePropagation added in v0.2.1

func (e *BaseEvent) StopImmediatePropagation()

func (*BaseEvent) StopPropagation added in v0.2.1

func (e *BaseEvent) StopPropagation()

func (*BaseEvent) Target

func (e *BaseEvent) Target() *Element

func (*BaseEvent) Type

func (e *BaseEvent) Type() string

type Button

type Button struct {
	Element
}

func NewButton added in v0.2.1

func NewButton(s string) *Button

func (*Button) OnClick

func (b *Button) OnClick(h EventHandler)

type Color

type Color string

type Document

type Document struct {
	NodeBase
}

func GetDocument

func GetDocument() *Document

func (*Document) CreateElement

func (d *Document) CreateElement(tag string) *Element

func (*Document) CreateElementNS

func (d *Document) CreateElementNS(ns string, tag string) *Element

func (*Document) GetElementById

func (d *Document) GetElementById(id string) *Element

func (*Document) GetElementsByTagName

func (d *Document) GetElementsByTagName(tag string) NodeList

func (*Document) NewButton

func (d *Document) NewButton(s string) *Button

func (*Document) NewInput

func (d *Document) NewInput(typ string) *Input

func (*Document) QuerySelector

func (d *Document) QuerySelector(qu string) *Element

func (*Document) QuerySelectorAll

func (d *Document) QuerySelectorAll(qu string) NodeList

type Element

type Element struct {
	NodeBase
}

func AsElement

func AsElement(v js.Value) *Element

func NewElement added in v0.2.1

func NewElement(tag string) *Element

func (*Element) AsHTMLElement added in v0.4.0

func (e *Element) AsHTMLElement() *HTMLElement

func (*Element) AttachShadow added in v0.4.0

func (e *Element) AttachShadow(opts AttachShadowOpts) *ShadowRoot

func (*Element) ClassList added in v0.4.0

func (e *Element) ClassList() *TokenList

ClassList returns a DOMTokenList containing the list of class attributes.

func (*Element) ClassName added in v0.4.0

func (e *Element) ClassName() string

ClassName is a DOMString representing the class of the element.

func (*Element) ClientHeight added in v0.4.0

func (e *Element) ClientHeight() int

ClientHeight returns a Number representing the inner height of the element.

func (*Element) ClientLeft added in v0.4.0

func (e *Element) ClientLeft() int

ClientLeft returns a Number representing the width of the left border of the element.

func (*Element) ClientTop added in v0.4.0

func (e *Element) ClientTop() int

ClientTop returns a Number representing the width of the top border of the element.

func (*Element) ClientWidth added in v0.4.0

func (e *Element) ClientWidth() int

ClientWidth returns a Number representing the inner width of the element.

func (*Element) ComputedName added in v0.4.0

func (e *Element) ComputedName() string

ComputedName returns a DOMString containing the label exposed to accessibility.

func (*Element) ComputedRole added in v0.4.0

func (e *Element) ComputedRole() string

ComputedRole returns a DOMString containing the ARIA role that has been applied to a particular element.

func (*Element) GetAttribute

func (e *Element) GetAttribute(k string) js.Value

func (*Element) GetBoundingClientRect

func (e *Element) GetBoundingClientRect() Rect

func (*Element) Id added in v0.4.0

func (e *Element) Id() string

Id is a DOMString representing the id of the element.

func (*Element) InnerHTML added in v0.4.0

func (e *Element) InnerHTML() string

InnerHTML is a DOMString representing the markup of the element's content.

func (*Element) InsertAdjacentElement added in v0.4.0

func (e *Element) InsertAdjacentElement(position Position, newElement *Element) js.Value

InsertAdjacentElement inserts a given element node at a given position relative to the element it is invoked upon.

func (*Element) LocalName added in v0.4.0

func (e *Element) LocalName() string

LocalName a DOMString representing the local part of the qualified name of the element.

func (*Element) NamespaceURI added in v0.4.0

func (e *Element) NamespaceURI() string

NamespaceURI the namespace URI of the element, or null if it is no namespace.

func (*Element) OnClick

func (e *Element) OnClick(h MouseEventHandler)

func (*Element) OnMouseDown

func (e *Element) OnMouseDown(h MouseEventHandler)

func (*Element) OnMouseMove

func (e *Element) OnMouseMove(h MouseEventHandler)

func (*Element) OnMouseUp

func (e *Element) OnMouseUp(h MouseEventHandler)

func (*Element) OuterHTML added in v0.4.0

func (e *Element) OuterHTML() string

OuterHTML is a DOMString representing the markup of the element including its content. When used as a setter, replaces the element with nodes parsed from the given string.

func (*Element) Prefix added in v0.4.0

func (e *Element) Prefix() string

Prefix a DOMString representing the namespace prefix of the element, or null if no prefix is specified.

func (*Element) RemoveAttribute added in v0.4.0

func (e *Element) RemoveAttribute(k string)

func (*Element) ScrollHeight added in v0.4.0

func (e *Element) ScrollHeight() int

ScrollHeight returns a Number representing the scroll view height of an element.

func (*Element) ScrollLeft added in v0.4.0

func (e *Element) ScrollLeft() int

ScrollLeft is a Number representing the left scroll offset of the element.

func (*Element) ScrollLeftMax added in v0.4.0

func (e *Element) ScrollLeftMax() int

ScrollLeftMax returns a Number representing the maximum left scroll offset possible for the element.

func (*Element) ScrollTop added in v0.4.0

func (e *Element) ScrollTop() int

ScrollTop a Number representing number of pixels the top of the document is scrolled vertically.

func (*Element) ScrollTopMax added in v0.4.0

func (e *Element) ScrollTopMax() int

ScrollTopMax returns a Number representing the maximum top scroll offset possible for the element.

func (*Element) ScrollWidth added in v0.4.0

func (e *Element) ScrollWidth() int

ScrollWidth returns a Number representing the scroll view width of the element.

func (*Element) SetAttribute

func (e *Element) SetAttribute(k string, v interface{})

func (*Element) SetClassName added in v0.4.0

func (e *Element) SetClassName(v string)

SetClassName is a DOMString representing the class of the element.

func (*Element) SetId added in v0.4.0

func (e *Element) SetId(v string)

SetId is a DOMString representing the id of the element.

func (*Element) SetInnerHTML

func (e *Element) SetInnerHTML(v string)

SetInnerHTML is a DOMString representing the markup of the element's content.

func (*Element) SetOuterHTML added in v0.4.0

func (e *Element) SetOuterHTML(v string)

SetOuterHTML is a DOMString representing the markup of the element including its content. When used as a setter, replaces the element with nodes parsed from the given string.

func (*Element) SetScrollLeft added in v0.4.0

func (e *Element) SetScrollLeft(v int)

SetScrollLeft is a Number representing the left scroll offset of the element.

func (*Element) SetScrollTop added in v0.4.0

func (e *Element) SetScrollTop(v int)

SetScrollTop a Number representing number of pixels the top of the document is scrolled vertically.

func (*Element) SetSlot added in v0.4.0

func (e *Element) SetSlot(v string)

SetSlot returns the name of the shadow DOM slot the element is inserted in.

func (*Element) SetTabStop added in v0.4.0

func (e *Element) SetTabStop(v bool)

SetTabStop is a Boolean indicating if the element can receive input focus via the tab key.

func (*Element) SetUndoScope added in v0.4.0

func (e *Element) SetUndoScope(v bool)

SetUndoScope is a Boolean indicating if the element is an undo scope host, or not.

func (*Element) ShadowRoot added in v0.4.0

func (e *Element) ShadowRoot() *ShadowRoot

Shadow returns the open shadow root that is hosted by the element, or null if no open shadow root is present.

func (*Element) Slot added in v0.4.0

func (e *Element) Slot() string

Slot returns the name of the shadow DOM slot the element is inserted in.

func (*Element) TabStop added in v0.4.0

func (e *Element) TabStop() bool

TabStop is a Boolean indicating if the element can receive input focus via the tab key.

func (*Element) TagName added in v0.4.0

func (e *Element) TagName() string

TagName returns a String with the name of the tag for the given element.

func (*Element) UndoManager added in v0.4.0

func (e *Element) UndoManager() js.Value

UndoManager returns the UndoManager associated with the element.

func (*Element) UndoScope added in v0.4.0

func (e *Element) UndoScope() bool

UndoScope is a Boolean indicating if the element is an undo scope host, or not.

type Em

type Em float64

func (Em) String

func (v Em) String() string

type Event

type Event interface {
	js.Wrapper
	Bubbles() bool
	Cancelable() bool
	Composed() bool
	CurrentTarget() *Element
	DefaultPrevented() bool
	Target() *Element
	Type() string
	IsTrusted() bool
	Path() NodeList

	PreventDefault()
	StopPropagation()
	StopImmediatePropagation()
}

type EventConstructor

type EventConstructor func(e BaseEvent) Event

type EventHandler

type EventHandler func(Event)

type EventTarget

type EventTarget interface {
	js.Wrapper
	AddEventListener(typ string, h EventHandler)
}

type HTMLElement added in v0.4.0

type HTMLElement struct {
	Element
}

func (*HTMLElement) AccessKey added in v0.4.0

func (e *HTMLElement) AccessKey() string

AccessKey is a DOMString representing the access key assigned to the element.

func (*HTMLElement) AccessKeyLabel added in v0.4.0

func (e *HTMLElement) AccessKeyLabel() string

AccessKeyLabel returns a DOMString containing the element's assigned access key.

func (*HTMLElement) ContentEditable added in v0.4.0

func (e *HTMLElement) ContentEditable() string

ContentEditable is a DOMString, where a value of "true" means the element is editable and a value of "false" means it isn't.

func (*HTMLElement) Dataset added in v0.4.0

func (e *HTMLElement) Dataset() js.Value

Dataset returns a DOMStringMap with which script can read and write the element's custom data attributes (data-*) .

func (*HTMLElement) Dir added in v0.4.0

func (e *HTMLElement) Dir() string

Dir is a DOMString, reflecting the dir global attribute, representing the directionality of the element. Possible values are "ltr", "rtl", and "auto".

func (*HTMLElement) Draggable added in v0.4.0

func (e *HTMLElement) Draggable() bool

Draggable is a Boolean indicating if the element can be dragged.

func (*HTMLElement) Dropzone added in v0.4.0

func (e *HTMLElement) Dropzone() *TokenList

Dropzone returns a DOMSettableTokenList reflecting the dropzone global attribute and describing the behavior of the element regarding a drop operation.

func (*HTMLElement) Hidden added in v0.4.0

func (e *HTMLElement) Hidden() bool

Hidden is a Boolean indicating if the element is hidden or not.

func (*HTMLElement) Inert added in v0.4.0

func (e *HTMLElement) Inert() bool

Inert is a Boolean indicating whether the user agent must act as though the given node is absent for the purposes of user interaction events, in-page text searches ("find in page"), and text selection.

func (*HTMLElement) InnerText added in v0.4.0

func (e *HTMLElement) InnerText() string

InnerText represents the "rendered" text content of a node and its descendants. As a getter, it approximates the text the user would get if they highlighted the contents of the element with the cursor and then copied it to the clipboard.

func (*HTMLElement) IsContentEditable added in v0.4.0

func (e *HTMLElement) IsContentEditable() bool

IsContentEditable returns a Boolean that indicates whether or not the content of the element can be edited.

func (*HTMLElement) ItemId added in v0.4.0

func (e *HTMLElement) ItemId() string

ItemId is a DOMString representing the item ID.

func (*HTMLElement) ItemProp added in v0.4.0

func (e *HTMLElement) ItemProp() *TokenList

ItemProp returns a DOMSettableTokenList…

func (*HTMLElement) ItemRef added in v0.4.0

func (e *HTMLElement) ItemRef() *TokenList

ItemRef returns a DOMSettableTokenList…

func (*HTMLElement) ItemScope added in v0.4.0

func (e *HTMLElement) ItemScope() bool

ItemScope is a Boolean representing the item scope.

func (*HTMLElement) ItemType added in v0.4.0

func (e *HTMLElement) ItemType() *TokenList

ItemType returns a DOMSettableTokenList…

func (*HTMLElement) ItemValue added in v0.4.0

func (e *HTMLElement) ItemValue() js.Value

ItemValue returns a Object representing the item value.

func (*HTMLElement) Lang added in v0.4.0

func (e *HTMLElement) Lang() string

Lang is a DOMString representing the language of an element's attributes, text, and element contents.

func (*HTMLElement) NoModule added in v0.4.0

func (e *HTMLElement) NoModule() bool

NoModule is a Boolean indicating whether an import script can be executed in user agents that support module scripts.

func (*HTMLElement) Nonce added in v0.4.0

func (e *HTMLElement) Nonce() js.Value

Nonce returns the cryptographic number used once that is used by Content Security Policy to determine whether a given fetch will be allowed to proceed.

func (*HTMLElement) OffsetHeight added in v0.4.0

func (e *HTMLElement) OffsetHeight() float64

OffsetHeight returns a double containing the height of an element, relative to the layout.

func (*HTMLElement) OffsetLeft added in v0.4.0

func (e *HTMLElement) OffsetLeft() float64

OffsetLeft returns a double, the distance from this element's left border to its offsetParent's left border.

func (*HTMLElement) OffsetParent added in v0.4.0

func (e *HTMLElement) OffsetParent() *Element

OffsetParent returns a Element that is the element from which all offset calculations are currently computed.

func (*HTMLElement) OffsetTop added in v0.4.0

func (e *HTMLElement) OffsetTop() float64

OffsetTop returns a double, the distance from this element's top border to its offsetParent's top border.

func (*HTMLElement) OffsetWidth added in v0.4.0

func (e *HTMLElement) OffsetWidth() float64

OffsetWidth returns a double containing the width of an element, relative to the layout.

func (*HTMLElement) SetAccessKey added in v0.4.0

func (e *HTMLElement) SetAccessKey(v string)

SetAccessKey is a DOMString representing the access key assigned to the element.

func (*HTMLElement) SetContentEditable added in v0.4.0

func (e *HTMLElement) SetContentEditable(v string)

SetContentEditable is a DOMString, where a value of "true" means the element is editable and a value of "false" means it isn't.

func (*HTMLElement) SetDir added in v0.4.0

func (e *HTMLElement) SetDir(v string)

SetDir is a DOMString, reflecting the dir global attribute, representing the directionality of the element. Possible values are "ltr", "rtl", and "auto".

func (*HTMLElement) SetDraggable added in v0.4.0

func (e *HTMLElement) SetDraggable(v bool)

SetDraggable is a Boolean indicating if the element can be dragged.

func (*HTMLElement) SetHidden added in v0.4.0

func (e *HTMLElement) SetHidden(v bool)

SetHidden is a Boolean indicating if the element is hidden or not.

func (*HTMLElement) SetInert added in v0.4.0

func (e *HTMLElement) SetInert(v bool)

SetInert is a Boolean indicating whether the user agent must act as though the given node is absent for the purposes of user interaction events, in-page text searches ("find in page"), and text selection.

func (*HTMLElement) SetInnerText added in v0.4.0

func (e *HTMLElement) SetInnerText(v string)

SetInnerText represents the "rendered" text content of a node and its descendants. As a getter, it approximates the text the user would get if they highlighted the contents of the element with the cursor and then copied it to the clipboard.

func (*HTMLElement) SetItemId added in v0.4.0

func (e *HTMLElement) SetItemId(v string)

SetItemId is a DOMString representing the item ID.

func (*HTMLElement) SetItemScope added in v0.4.0

func (e *HTMLElement) SetItemScope(v bool)

SetItemScope is a Boolean representing the item scope.

func (*HTMLElement) SetItemValue added in v0.4.0

func (e *HTMLElement) SetItemValue(v js.Value)

SetItemValue returns a Object representing the item value.

func (*HTMLElement) SetLang added in v0.4.0

func (e *HTMLElement) SetLang(v string)

SetLang is a DOMString representing the language of an element's attributes, text, and element contents.

func (*HTMLElement) SetNoModule added in v0.4.0

func (e *HTMLElement) SetNoModule(v bool)

SetNoModule is a Boolean indicating whether an import script can be executed in user agents that support module scripts.

func (*HTMLElement) SetNonce added in v0.4.0

func (e *HTMLElement) SetNonce(v js.Value)

SetNonce returns the cryptographic number used once that is used by Content Security Policy to determine whether a given fetch will be allowed to proceed.

func (*HTMLElement) SetSpellcheck added in v0.4.0

func (e *HTMLElement) SetSpellcheck(v bool)

SetSpellcheck is a Boolean that controls spell-checking. It is present on all HTML elements, though it doesn't have an effect on all of them.

func (*HTMLElement) SetStyle added in v0.4.0

func (e *HTMLElement) SetStyle(v *Style)

SetStyle is a CSSStyleDeclaration, an object representing the declarations of an element's style attributes.

func (*HTMLElement) SetTabIndex added in v0.4.0

func (e *HTMLElement) SetTabIndex(v int)

SetTabIndex is a long representing the position of the element in the tabbing order.

func (*HTMLElement) SetTitle added in v0.4.0

func (e *HTMLElement) SetTitle(v string)

SetTitle is a DOMString containing the text that appears in a popup box when mouse is over the element.

func (*HTMLElement) SetTranslate added in v0.4.0

func (e *HTMLElement) SetTranslate(v bool)

SetTranslate is a Boolean representing the translation.

func (*HTMLElement) Spellcheck added in v0.4.0

func (e *HTMLElement) Spellcheck() bool

Spellcheck is a Boolean that controls spell-checking. It is present on all HTML elements, though it doesn't have an effect on all of them.

func (*HTMLElement) Style added in v0.4.0

func (e *HTMLElement) Style() *Style

Style is a CSSStyleDeclaration, an object representing the declarations of an element's style attributes.

func (*HTMLElement) TabIndex added in v0.4.0

func (e *HTMLElement) TabIndex() int

TabIndex is a long representing the position of the element in the tabbing order.

func (*HTMLElement) Title added in v0.4.0

func (e *HTMLElement) Title() string

Title is a DOMString containing the text that appears in a popup box when mouse is over the element.

func (*HTMLElement) Translate added in v0.4.0

func (e *HTMLElement) Translate() bool

Translate is a Boolean representing the translation.

type Input

type Input struct {
	HTMLElement
}

func NewInput added in v0.2.1

func NewInput(typ string) *Input

func (*Input) OnChange

func (inp *Input) OnChange(h EventHandler)

func (*Input) OnInput

func (inp *Input) OnInput(h EventHandler)

func (*Input) SetName

func (inp *Input) SetName(name string)

func (*Input) SetType

func (inp *Input) SetType(typ string)

func (*Input) SetValue

func (inp *Input) SetValue(val interface{})

func (*Input) Value

func (inp *Input) Value() string

type MouseButton

type MouseButton int

type MouseEvent

type MouseEvent struct {
	BaseEvent
}

func (*MouseEvent) AltKey

func (e *MouseEvent) AltKey() bool

func (*MouseEvent) Button

func (e *MouseEvent) Button() MouseButton

func (*MouseEvent) ClientPos

func (e *MouseEvent) ClientPos() Point

func (*MouseEvent) CtrlKey

func (e *MouseEvent) CtrlKey() bool

func (*MouseEvent) MetaKey

func (e *MouseEvent) MetaKey() bool

func (*MouseEvent) OffsetPos

func (e *MouseEvent) OffsetPos() Point

func (*MouseEvent) PagePos

func (e *MouseEvent) PagePos() Point

func (*MouseEvent) ScreenPos

func (e *MouseEvent) ScreenPos() Point

func (*MouseEvent) ShiftKey

func (e *MouseEvent) ShiftKey() bool

type MouseEventHandler

type MouseEventHandler func(*MouseEvent)

type Node

type Node interface {
	EventTarget

	BaseURI() string
	NodeName() string
	ChildNodes() NodeList
	ParentNode() Node
	ParentElement() *Element
	TextContent() string
	SetTextContent(s string)

	AppendChild(n Node)
	Contains(n Node) bool
	IsEqualNode(n Node) bool
	IsSameNode(n Node) bool
	RemoveChild(n Node) Node
	ReplaceChild(n, old Node) Node
}

type NodeBase

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

func (*NodeBase) AddErrorListener added in v0.4.0

func (e *NodeBase) AddErrorListener(h func(err error))

func (*NodeBase) AddEventListener

func (e *NodeBase) AddEventListener(typ string, h EventHandler)

func (*NodeBase) AppendChild

func (e *NodeBase) AppendChild(n Node)

func (*NodeBase) BaseURI

func (e *NodeBase) BaseURI() string

func (*NodeBase) ChildNodes

func (e *NodeBase) ChildNodes() NodeList

func (*NodeBase) Contains

func (e *NodeBase) Contains(n Node) bool

func (*NodeBase) IsEqualNode

func (e *NodeBase) IsEqualNode(n Node) bool

func (*NodeBase) IsSameNode

func (e *NodeBase) IsSameNode(n Node) bool

func (NodeBase) JSValue added in v0.4.0

func (e NodeBase) JSValue() js.Ref

JSValue implements js.Wrapper.

func (*NodeBase) NodeName

func (e *NodeBase) NodeName() string

func (*NodeBase) NodeType added in v0.4.0

func (e *NodeBase) NodeType() NodeType

func (*NodeBase) ParentElement

func (e *NodeBase) ParentElement() *Element

func (*NodeBase) ParentNode

func (e *NodeBase) ParentNode() Node

func (*NodeBase) Remove

func (e *NodeBase) Remove()

func (*NodeBase) RemoveChild

func (e *NodeBase) RemoveChild(n Node) Node

func (*NodeBase) ReplaceChild

func (e *NodeBase) ReplaceChild(n, old Node) Node

func (*NodeBase) SetTextContent

func (e *NodeBase) SetTextContent(s string)

func (*NodeBase) TextContent

func (e *NodeBase) TextContent() string

type NodeList

type NodeList []*Element

func AsNodeList

func AsNodeList(v js.Value) NodeList

type NodeType added in v0.4.0

type NodeType int
const (
	ElementNode               NodeType = 1
	TextNode                  NodeType = 3
	CDataSectionNode          NodeType = 4
	ProcessingInstructionNode NodeType = 7
	CommentNode               NodeType = 8
	DocumentNode              NodeType = 9
	DocumentTypeNode          NodeType = 10
	DocumentFragmentNode      NodeType = 11
)

See https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants

type Perc

type Perc int

func (Perc) String

func (v Perc) String() string

type Point

type Point = image.Point

type Position added in v0.4.0

type Position string
const (
	BeforeBegin Position = "beforebegin"
	BeforeEnd   Position = "beforeend"
	AfterBegin  Position = "afterbegin"
	AfterEnd    Position = "afterend"
)

type Px

type Px int

func (Px) String

func (v Px) String() string

type Rect

type Rect = image.Rectangle

type Rem

type Rem int

func (Rem) String

func (v Rem) String() string

type ShadowRoot added in v0.4.0

type ShadowRoot struct {
	NodeBase
}

func AsShadowRoot added in v0.4.0

func AsShadowRoot(v js.Value) *ShadowRoot

func (*ShadowRoot) Host added in v0.4.0

func (r *ShadowRoot) Host() *Element

func (*ShadowRoot) InnerHTML added in v0.4.0

func (r *ShadowRoot) InnerHTML() string

func (*ShadowRoot) IsOpen added in v0.4.0

func (r *ShadowRoot) IsOpen() bool

func (*ShadowRoot) SetInnerHTML added in v0.4.0

func (r *ShadowRoot) SetInnerHTML(s string)

type Style

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

func AsStyle added in v0.4.0

func AsStyle(v js.Value) *Style

func (*Style) Set

func (s *Style) Set(k string, v interface{})

func (*Style) SetHeight

func (s *Style) SetHeight(v Unit)

func (*Style) SetMarginsRaw

func (s *Style) SetMarginsRaw(m string)

func (*Style) SetWidth

func (s *Style) SetWidth(v Unit)

type TokenList added in v0.4.0

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

func AsTokenList added in v0.4.0

func AsTokenList(v js.Value) *TokenList

func (*TokenList) Add added in v0.4.0

func (t *TokenList) Add(class ...interface{})

func (*TokenList) Remove added in v0.4.0

func (t *TokenList) Remove(class ...interface{})

type Unit

type Unit interface {
	String() string
}

type Value

type Value = js.Wrapper

Value is an alias for js.Wrapper.

Derprecated: use js.Wrapper

type Vh

type Vh int

func (Vh) String

func (v Vh) String() string

type Vmax

type Vmax int

func (Vmax) String

func (v Vmax) String() string

type Vmin

type Vmin int

func (Vmin) String

func (v Vmin) String() string

type Vw

type Vw int

func (Vw) String

func (v Vw) String() string

type Window

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

func GetWindow

func GetWindow() *Window

func (*Window) AddEventListener

func (w *Window) AddEventListener(typ string, h EventHandler)

func (*Window) JSValue added in v0.4.0

func (w *Window) JSValue() js.Ref

func (*Window) OnResize

func (w *Window) OnResize(fnc func(e Event))

func (*Window) Open added in v0.4.0

func (w *Window) Open(url, windowName string, windowFeatures map[string]string)

func (*Window) SetLocation added in v0.4.0

func (w *Window) SetLocation(url string)

Directories

Path Synopsis
cmd
app
examples module
extension
chrome/native
Package native provides an API for Native Messaging for Chrome extensions.
Package native provides an API for Native Messaging for Chrome extensions.
internal
js
Package JS provides additional functionality on top of syscall/js package for WASM.
Package JS provides additional functionality on top of syscall/js package for WASM.
net
ws
Package ws provides a functionality similar to Go net package on top of WebSockets.
Package ws provides a functionality similar to Go net package on top of WebSockets.

Jump to

Keyboard shortcuts

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