dom

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dom はWebGoスクリプト向けのDOM APIを提供する。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API は1ページのDocumentへアクセスする。

func New

func New(document *dommodel.Document, dispatcher *events.Dispatcher, onMutation func()) *API

New はDocumentに結び付いたDOM APIを生成する。

func (*API) Body added in v0.15.0

func (api *API) Body() *Element

Body returns the connected body element.

func (*API) CreateDocumentFragment added in v0.15.0

func (api *API) CreateDocumentFragment() *Element

CreateDocumentFragment returns a detached fragment owned by this Document.

func (*API) CreateElement

func (api *API) CreateElement(tagName string) *Element

CreateElement はDocumentが所有する未接続の要素を作成する。

func (*API) CreateElementNS added in v0.15.0

func (api *API) CreateElementNS(namespace, tagName string) *Element

CreateElementNS supports the HTML and SVG namespaces used by hydration fixtures.

func (*API) CreateTextNode added in v0.14.0

func (api *API) CreateTextNode(value string) *Element

CreateTextNode creates a bounded detached text node owned by the Document.

func (*API) DocumentElement added in v0.15.0

func (api *API) DocumentElement() *Element

DocumentElement returns the connected root HTML element.

func (*API) ElementByNodeID added in v0.14.0

func (api *API) ElementByNodeID(id dommodel.NodeID) *Element

ElementByNodeID returns a connected node handle by its document-scoped identity.

func (*API) GetElementByID

func (api *API) GetElementByID(id string) *Element

GetElementByID は指定したidを持つ最初の要素を返す。

func (*API) GetElementsByClassName added in v0.14.0

func (api *API) GetElementsByClassName(classNames string) []*Element

GetElementsByClassName returns a bounded static collection for class tokens.

func (*API) GetElementsByTagName added in v0.14.0

func (api *API) GetElementsByTagName(tagName string) []*Element

GetElementsByTagName returns a bounded static collection for a tag name.

func (*API) Head added in v0.15.0

func (api *API) Head() *Element

Head returns the connected head element.

func (*API) ImportNode added in v0.15.0

func (api *API) ImportNode(source *Element, deep bool) *Element

ImportNode clones a node into this Document without connecting it.

func (*API) NodeByID added in v0.15.0

func (api *API) NodeByID(id dommodel.NodeID) *Element

NodeByID returns a handle for connected or detached nodes owned by this Document.

func (*API) QuerySelector

func (api *API) QuerySelector(selector string) *Element

QuerySelector は対応する単純セレクターに最初に一致する要素を返す。

func (*API) QuerySelectorAll added in v0.14.0

func (api *API) QuerySelectorAll(selector string) []*Element

QuerySelectorAll returns a bounded static collection for a supported selector.

type Element

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

Element はDocument内の要素をNodeIDで参照する。

func (*Element) AddClass

func (element *Element) AddClass(className string) bool

AddClass は重複を避けてクラスを追加する。

func (*Element) AddEventListener added in v0.13.0

func (element *Element) AddEventListener(eventType string, handler func(Event)) bool

AddEventListener はJavaScript hostを含むRuntime adapter向けに対応Eventを登録する。

func (*Element) AddEventListenerForJavaScript added in v0.15.0

func (element *Element) AddEventListenerForJavaScript(eventType string, capture bool, handler func(Event)) events.ListenerID

AddEventListenerForJavaScript registers EventTarget listeners on Document-owned detached nodes so JavaScript can attach handlers before connecting an element.

func (*Element) AddEventListenerForJavaScriptWithOptions added in v0.15.0

func (element *Element) AddEventListenerForJavaScriptWithOptions(eventType string, capture, once, passive bool, handler func(Event)) events.ListenerID

AddEventListenerForJavaScriptWithOptions registers a detached-capable JS listener.

func (*Element) AddEventListenerWithCapture added in v0.14.0

func (element *Element) AddEventListenerWithCapture(eventType string, capture bool, handler func(Event)) events.ListenerID

AddEventListenerWithCapture registers a removable listener with propagation options.

func (*Element) Append added in v0.14.0

func (element *Element) Append(children ...*Element) bool

Append moves nodes to the end of this element's child list.

func (*Element) AppendChild

func (element *Element) AppendChild(child *Element) bool

AppendChild は未接続の子要素を接続済みの要素の末尾へ追加する。

func (*Element) AttributeNames added in v0.15.0

func (element *Element) AttributeNames() []string

AttributeNames returns a stable sorted snapshot of attribute names.

func (*Element) ChildNodes added in v0.15.0

func (element *Element) ChildNodes() []*Element

ChildNodes returns a bounded static snapshot of direct DOM children.

func (*Element) Children added in v0.14.0

func (element *Element) Children() []*Element

Children returns a bounded static collection of direct element children.

func (*Element) ClassName added in v0.14.0

func (element *Element) ClassName() string

ClassName returns the normalized class attribute string.

func (*Element) CloneNode added in v0.15.0

func (element *Element) CloneNode(deep bool) *Element

CloneNode returns a detached shallow or deep clone owned by the same Document.

func (*Element) Closest added in v0.15.0

func (element *Element) Closest(selector string) *Element

Closest returns this element or its nearest element ancestor matching selector.

func (*Element) Contains added in v0.15.0

func (element *Element) Contains(candidate *Element) bool

Contains reports inclusive descendant membership without crossing template fragments.

func (*Element) ContainsClass added in v0.14.0

func (element *Element) ContainsClass(className string) bool

ContainsClass reports whether className is present.

func (*Element) FirstChild added in v0.15.0

func (element *Element) FirstChild() *Element

FirstChild returns the first child Node.

func (*Element) GetAttribute

func (element *Element) GetAttribute(name string) (string, bool)

GetAttribute は要素に設定された属性値を返す。

func (*Element) HasAttribute added in v0.15.0

func (element *Element) HasAttribute(name string) bool

HasAttribute reports whether an attribute is present.

func (*Element) ID added in v0.13.0

func (element *Element) ID() dommodel.NodeID

ID はElementが参照するPage内Node IDを返す。

func (*Element) IDValue added in v0.14.0

func (element *Element) IDValue() string

IDValue returns the id attribute.

func (*Element) InlineStyleProperty added in v0.15.0

func (element *Element) InlineStyleProperty(name string) (value, priority string)

InlineStyleProperty returns the last inline declaration value and priority.

func (*Element) InlineStylePropertyNames added in v0.15.0

func (element *Element) InlineStylePropertyNames() []string

InlineStylePropertyNames returns declaration names in source order.

func (*Element) InlineStyleText added in v0.15.0

func (element *Element) InlineStyleText() string

InlineStyleText returns the normalized serialized style attribute.

func (*Element) InnerHTML added in v0.14.0

func (element *Element) InnerHTML() string

InnerHTML serializes this element's children.

func (*Element) InsertAdjacentHTML added in v0.15.0

func (element *Element) InsertAdjacentHTML(position, value string) ([]*Element, bool)

InsertAdjacentHTML parses and inserts HTML at one of the four standard positions.

func (*Element) InsertBefore added in v0.15.0

func (element *Element) InsertBefore(child, reference *Element) bool

InsertBefore inserts or moves child immediately before reference. A nil reference appends.

func (*Element) IsConnected added in v0.15.0

func (element *Element) IsConnected() bool

IsConnected reports whether this handle currently participates in its Document tree.

func (*Element) LastChild added in v0.15.0

func (element *Element) LastChild() *Element

LastChild returns the last child Node.

func (*Element) Matches added in v0.15.0

func (element *Element) Matches(selector string) bool

Matches evaluates a supported selector list against this element.

func (*Element) NextSibling added in v0.15.0

func (element *Element) NextSibling() *Element

NextSibling returns the following sibling Node.

func (*Element) NodeName added in v0.15.0

func (element *Element) NodeName() string

NodeName returns the DOM-facing node name.

func (*Element) NodeType added in v0.15.0

func (element *Element) NodeType() dommodel.NodeType

NodeType returns the browser-owned node kind.

func (*Element) OnBlur added in v0.8.0

func (element *Element) OnBlur(handler func(Event))

OnBlur は要素がfocusを失ったハンドラーを登録する。

func (*Element) OnChange

func (element *Element) OnChange(handler func(Event))

OnChange は入力の編集確定ハンドラーを登録する。

func (*Element) OnClick

func (element *Element) OnClick(handler func())

OnClick は要素のクリックイベントへハンドラーを登録する。

func (*Element) OnClickEvent

func (element *Element) OnClickEvent(handler func(Event))

OnClickEvent はクリックイベント情報を受け取るハンドラーを登録する。

func (*Element) OnFocus added in v0.8.0

func (element *Element) OnFocus(handler func(Event))

OnFocus は要素がfocusを得たハンドラーを登録する。

func (*Element) OnInput

func (element *Element) OnInput(handler func(Event))

OnInput はユーザー操作による入力値変更のハンドラーを登録する。

func (*Element) OnMouseEnter

func (element *Element) OnMouseEnter(handler func(Event))

OnMouseEnter はポインターが要素へ入ったときのハンドラーを登録する。

func (*Element) OnMouseLeave

func (element *Element) OnMouseLeave(handler func(Event))

OnMouseLeave はポインターが要素から外れたときのハンドラーを登録する。

func (*Element) OnReset added in v0.8.0

func (element *Element) OnReset(handler func(Event))

OnReset はformのresetハンドラーを登録する。

func (*Element) OnSubmit

func (element *Element) OnSubmit(handler func(Event))

OnSubmit はformの送信操作ハンドラーを登録する。

func (*Element) OuterHTML added in v0.15.0

func (element *Element) OuterHTML() string

OuterHTML serializes this element and its subtree.

func (*Element) ParentElement added in v0.14.0

func (element *Element) ParentElement() *Element

ParentElement returns the connected element parent, excluding the Document node.

func (*Element) ParentNode added in v0.15.0

func (element *Element) ParentNode() *Element

ParentNode returns the parent Node, including a DocumentFragment or Document.

func (*Element) Prepend added in v0.14.0

func (element *Element) Prepend(children ...*Element) bool

Prepend moves nodes to the beginning of this element's child list.

func (*Element) PreviousSibling added in v0.15.0

func (element *Element) PreviousSibling() *Element

PreviousSibling returns the preceding sibling Node.

func (*Element) QuerySelector added in v0.15.0

func (element *Element) QuerySelector(selector string) *Element

QuerySelector returns the first matching descendant.

func (*Element) QuerySelectorAll added in v0.15.0

func (element *Element) QuerySelectorAll(selector string) []*Element

QuerySelectorAll returns a bounded static descendant snapshot.

func (*Element) Remove

func (element *Element) Remove() bool

Remove は要素自身とその子孫をDocumentから削除する。

func (*Element) RemoveAttribute added in v0.15.0

func (element *Element) RemoveAttribute(name string) bool

RemoveAttribute removes an element attribute and notifies the active Page once.

func (*Element) RemoveChild added in v0.14.0

func (element *Element) RemoveChild(child *Element) bool

RemoveChild detaches a direct child while retaining its Runtime identity.

func (*Element) RemoveClass

func (element *Element) RemoveClass(className string) bool

RemoveClass は指定したクラスを要素から削除する。

func (*Element) RemoveEventListener added in v0.14.0

func (element *Element) RemoveEventListener(eventType string, id events.ListenerID) bool

RemoveEventListener removes one listener token returned by AddEventListenerWithCapture.

func (*Element) RemoveInlineStyleProperty added in v0.15.0

func (element *Element) RemoveInlineStyleProperty(name string) string

RemoveInlineStyleProperty removes one declaration and returns its old value.

func (*Element) ReplaceChild added in v0.15.0

func (element *Element) ReplaceChild(child, replaced *Element) bool

ReplaceChild replaces a direct child while preserving the removed subtree identity.

func (*Element) ReplaceChildren added in v0.14.0

func (element *Element) ReplaceChildren(children ...*Element) bool

ReplaceChildren atomically replaces this element's children with supplied nodes.

func (*Element) Reset added in v0.8.0

func (element *Element) Reset() bool

Reset restores this form's controls to their default state.

func (*Element) SetAttribute

func (element *Element) SetAttribute(name, value string) bool

SetAttribute は要素の属性値を変更する。

func (*Element) SetClassName added in v0.14.0

func (element *Element) SetClassName(value string) bool

SetClassName updates the class attribute.

func (*Element) SetIDValue added in v0.14.0

func (element *Element) SetIDValue(value string) bool

SetIDValue updates the id attribute.

func (*Element) SetInlineStyleProperty added in v0.15.0

func (element *Element) SetInlineStyleProperty(name, value, priority string) bool

SetInlineStyleProperty validates and updates one inline declaration.

func (*Element) SetInlineStyleText added in v0.15.0

func (element *Element) SetInlineStyleText(value string) bool

SetInlineStyleText replaces the complete inline declaration list.

func (*Element) SetInnerHTML added in v0.14.0

func (element *Element) SetInnerHTML(value string) bool

SetInnerHTML parses and atomically replaces a bounded HTML fragment.

func (*Element) SetOuterHTML added in v0.15.0

func (element *Element) SetOuterHTML(value string) ([]*Element, bool)

SetOuterHTML replaces this element with a bounded parsed fragment.

func (*Element) SetText

func (element *Element) SetText(value string) bool

SetText は要素の内容を指定したテキストへ置き換える。

func (*Element) SetValue

func (element *Element) SetValue(value string) bool

SetValue はテキストinputの現在値を変更する。

func (*Element) TagName added in v0.14.0

func (element *Element) TagName() string

TagName returns the HTML tag name in ASCII uppercase.

func (*Element) TemplateContent added in v0.15.0

func (element *Element) TemplateContent() *Element

TemplateContent returns the detached DocumentFragment owned by a template.

func (*Element) Text

func (element *Element) Text() string

Text は要素と子孫のテキストを返す。

func (*Element) ToggleAttribute added in v0.15.0

func (element *Element) ToggleAttribute(name string, force *bool) (bool, bool)

ToggleAttribute adds or removes a boolean attribute and returns its resulting presence.

func (*Element) ToggleClass added in v0.14.0

func (element *Element) ToggleClass(className string, force *bool) bool

ToggleClass applies optional force and returns the resulting membership.

func (*Element) Value

func (element *Element) Value() string

Value はテキストinputの現在値を返す。

type Event

type Event struct {
	Type             string
	TargetID         string
	TargetNodeID     dommodel.NodeID
	CurrentTargetID  dommodel.NodeID
	Value            string
	X                float32
	Y                float32
	Bubbles          bool
	Cancelable       bool
	DefaultPrevented func() bool
	Phase            events.Phase
	RuntimeID        uint64
	// contains filtered or unexported fields
}

Event はWebGoへ公開するDOMイベント情報である。

func (Event) PreventDefault added in v0.8.0

func (event Event) PreventDefault()

PreventDefault cancels a cancelable browser default action such as form submission.

func (Event) StopImmediatePropagation added in v0.15.0

func (event Event) StopImmediatePropagation()

StopImmediatePropagation prevents later listeners and further propagation.

func (Event) StopPropagation added in v0.14.0

func (event Event) StopPropagation()

StopPropagation prevents this event from reaching later nodes on its path.

Jump to

Keyboard shortcuts

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