dom

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 4 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) CreateElement

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

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

func (*API) GetElementByID

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

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

func (*API) QuerySelector

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

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

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

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

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

func (*Element) GetAttribute

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

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

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

func (element *Element) Remove() bool

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

func (*Element) RemoveClass

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

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

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

func (element *Element) SetText(value string)

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

func (*Element) SetValue

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

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

func (*Element) Text

func (element *Element) Text() string

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

func (*Element) Value

func (element *Element) Value() string

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

type Event

type Event struct {
	Type     string
	TargetID string
	Value    string
	X        float32
	Y        float32
	// 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.

Jump to

Keyboard shortcuts

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