Documentation
¶
Overview ¶
Package dom はWebGoスクリプト向けのDOM APIを提供する。
Index ¶
- type API
- func (api *API) Body() *Element
- func (api *API) CreateDocumentFragment() *Element
- func (api *API) CreateElement(tagName string) *Element
- func (api *API) CreateElementNS(namespace, tagName string) *Element
- func (api *API) CreateTextNode(value string) *Element
- func (api *API) DocumentElement() *Element
- func (api *API) ElementByNodeID(id dommodel.NodeID) *Element
- func (api *API) GetElementByID(id string) *Element
- func (api *API) GetElementsByClassName(classNames string) []*Element
- func (api *API) GetElementsByTagName(tagName string) []*Element
- func (api *API) Head() *Element
- func (api *API) ImportNode(source *Element, deep bool) *Element
- func (api *API) NodeByID(id dommodel.NodeID) *Element
- func (api *API) QuerySelector(selector string) *Element
- func (api *API) QuerySelectorAll(selector string) []*Element
- type Element
- func (element *Element) AddClass(className string) bool
- func (element *Element) AddEventListener(eventType string, handler func(Event)) bool
- func (element *Element) AddEventListenerForJavaScript(eventType string, capture bool, handler func(Event)) events.ListenerID
- func (element *Element) AddEventListenerForJavaScriptWithOptions(eventType string, capture, once, passive bool, handler func(Event)) events.ListenerID
- func (element *Element) AddEventListenerWithCapture(eventType string, capture bool, handler func(Event)) events.ListenerID
- func (element *Element) Append(children ...*Element) bool
- func (element *Element) AppendChild(child *Element) bool
- func (element *Element) AttributeNames() []string
- func (element *Element) ChildNodes() []*Element
- func (element *Element) Children() []*Element
- func (element *Element) ClassName() string
- func (element *Element) CloneNode(deep bool) *Element
- func (element *Element) Closest(selector string) *Element
- func (element *Element) Contains(candidate *Element) bool
- func (element *Element) ContainsClass(className string) bool
- func (element *Element) FirstChild() *Element
- func (element *Element) GetAttribute(name string) (string, bool)
- func (element *Element) HasAttribute(name string) bool
- func (element *Element) ID() dommodel.NodeID
- func (element *Element) IDValue() string
- func (element *Element) InlineStyleProperty(name string) (value, priority string)
- func (element *Element) InlineStylePropertyNames() []string
- func (element *Element) InlineStyleText() string
- func (element *Element) InnerHTML() string
- func (element *Element) InsertAdjacentHTML(position, value string) ([]*Element, bool)
- func (element *Element) InsertBefore(child, reference *Element) bool
- func (element *Element) IsConnected() bool
- func (element *Element) LastChild() *Element
- func (element *Element) Matches(selector string) bool
- func (element *Element) NextSibling() *Element
- func (element *Element) NodeName() string
- func (element *Element) NodeType() dommodel.NodeType
- func (element *Element) OnBlur(handler func(Event))
- func (element *Element) OnChange(handler func(Event))
- func (element *Element) OnClick(handler func())
- func (element *Element) OnClickEvent(handler func(Event))
- func (element *Element) OnFocus(handler func(Event))
- func (element *Element) OnInput(handler func(Event))
- func (element *Element) OnMouseEnter(handler func(Event))
- func (element *Element) OnMouseLeave(handler func(Event))
- func (element *Element) OnReset(handler func(Event))
- func (element *Element) OnSubmit(handler func(Event))
- func (element *Element) OuterHTML() string
- func (element *Element) ParentElement() *Element
- func (element *Element) ParentNode() *Element
- func (element *Element) Prepend(children ...*Element) bool
- func (element *Element) PreviousSibling() *Element
- func (element *Element) QuerySelector(selector string) *Element
- func (element *Element) QuerySelectorAll(selector string) []*Element
- func (element *Element) Remove() bool
- func (element *Element) RemoveAttribute(name string) bool
- func (element *Element) RemoveChild(child *Element) bool
- func (element *Element) RemoveClass(className string) bool
- func (element *Element) RemoveEventListener(eventType string, id events.ListenerID) bool
- func (element *Element) RemoveInlineStyleProperty(name string) string
- func (element *Element) ReplaceChild(child, replaced *Element) bool
- func (element *Element) ReplaceChildren(children ...*Element) bool
- func (element *Element) Reset() bool
- func (element *Element) SetAttribute(name, value string) bool
- func (element *Element) SetClassName(value string) bool
- func (element *Element) SetIDValue(value string) bool
- func (element *Element) SetInlineStyleProperty(name, value, priority string) bool
- func (element *Element) SetInlineStyleText(value string) bool
- func (element *Element) SetInnerHTML(value string) bool
- func (element *Element) SetOuterHTML(value string) ([]*Element, bool)
- func (element *Element) SetText(value string) bool
- func (element *Element) SetValue(value string) bool
- func (element *Element) TagName() string
- func (element *Element) TemplateContent() *Element
- func (element *Element) Text() string
- func (element *Element) ToggleAttribute(name string, force *bool) (bool, bool)
- func (element *Element) ToggleClass(className string, force *bool) bool
- func (element *Element) Value() string
- type Event
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) CreateDocumentFragment ¶ added in v0.15.0
CreateDocumentFragment returns a detached fragment owned by this Document.
func (*API) CreateElement ¶
CreateElement はDocumentが所有する未接続の要素を作成する。
func (*API) CreateElementNS ¶ added in v0.15.0
CreateElementNS supports the HTML and SVG namespaces used by hydration fixtures.
func (*API) CreateTextNode ¶ added in v0.14.0
CreateTextNode creates a bounded detached text node owned by the Document.
func (*API) DocumentElement ¶ added in v0.15.0
DocumentElement returns the connected root HTML element.
func (*API) ElementByNodeID ¶ added in v0.14.0
ElementByNodeID returns a connected node handle by its document-scoped identity.
func (*API) GetElementByID ¶
GetElementByID は指定したidを持つ最初の要素を返す。
func (*API) GetElementsByClassName ¶ added in v0.14.0
GetElementsByClassName returns a bounded static collection for class tokens.
func (*API) GetElementsByTagName ¶ added in v0.14.0
GetElementsByTagName returns a bounded static collection for a tag name.
func (*API) ImportNode ¶ added in v0.15.0
ImportNode clones a node into this Document without connecting it.
func (*API) NodeByID ¶ added in v0.15.0
NodeByID returns a handle for connected or detached nodes owned by this Document.
func (*API) QuerySelector ¶
QuerySelector は対応する単純セレクターに最初に一致する要素を返す。
func (*API) QuerySelectorAll ¶ added in v0.14.0
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) AddEventListener ¶ added in v0.13.0
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
Append moves nodes to the end of this element's child list.
func (*Element) AppendChild ¶
AppendChild は未接続の子要素を接続済みの要素の末尾へ追加する。
func (*Element) AttributeNames ¶ added in v0.15.0
AttributeNames returns a stable sorted snapshot of attribute names.
func (*Element) ChildNodes ¶ added in v0.15.0
ChildNodes returns a bounded static snapshot of direct DOM children.
func (*Element) Children ¶ added in v0.14.0
Children returns a bounded static collection of direct element children.
func (*Element) ClassName ¶ added in v0.14.0
ClassName returns the normalized class attribute string.
func (*Element) CloneNode ¶ added in v0.15.0
CloneNode returns a detached shallow or deep clone owned by the same Document.
func (*Element) Closest ¶ added in v0.15.0
Closest returns this element or its nearest element ancestor matching selector.
func (*Element) Contains ¶ added in v0.15.0
Contains reports inclusive descendant membership without crossing template fragments.
func (*Element) ContainsClass ¶ added in v0.14.0
ContainsClass reports whether className is present.
func (*Element) FirstChild ¶ added in v0.15.0
FirstChild returns the first child Node.
func (*Element) GetAttribute ¶
GetAttribute は要素に設定された属性値を返す。
func (*Element) HasAttribute ¶ added in v0.15.0
HasAttribute reports whether an attribute is present.
func (*Element) InlineStyleProperty ¶ added in v0.15.0
InlineStyleProperty returns the last inline declaration value and priority.
func (*Element) InlineStylePropertyNames ¶ added in v0.15.0
InlineStylePropertyNames returns declaration names in source order.
func (*Element) InlineStyleText ¶ added in v0.15.0
InlineStyleText returns the normalized serialized style attribute.
func (*Element) InsertAdjacentHTML ¶ added in v0.15.0
InsertAdjacentHTML parses and inserts HTML at one of the four standard positions.
func (*Element) InsertBefore ¶ added in v0.15.0
InsertBefore inserts or moves child immediately before reference. A nil reference appends.
func (*Element) IsConnected ¶ added in v0.15.0
IsConnected reports whether this handle currently participates in its Document tree.
func (*Element) Matches ¶ added in v0.15.0
Matches evaluates a supported selector list against this element.
func (*Element) NextSibling ¶ added in v0.15.0
NextSibling returns the following sibling Node.
func (*Element) OnClick ¶
func (element *Element) OnClick(handler func())
OnClick は要素のクリックイベントへハンドラーを登録する。
func (*Element) OnClickEvent ¶
OnClickEvent はクリックイベント情報を受け取るハンドラーを登録する。
func (*Element) OnMouseEnter ¶
OnMouseEnter はポインターが要素へ入ったときのハンドラーを登録する。
func (*Element) OnMouseLeave ¶
OnMouseLeave はポインターが要素から外れたときのハンドラーを登録する。
func (*Element) ParentElement ¶ added in v0.14.0
ParentElement returns the connected element parent, excluding the Document node.
func (*Element) ParentNode ¶ added in v0.15.0
ParentNode returns the parent Node, including a DocumentFragment or Document.
func (*Element) Prepend ¶ added in v0.14.0
Prepend moves nodes to the beginning of this element's child list.
func (*Element) PreviousSibling ¶ added in v0.15.0
PreviousSibling returns the preceding sibling Node.
func (*Element) QuerySelector ¶ added in v0.15.0
QuerySelector returns the first matching descendant.
func (*Element) QuerySelectorAll ¶ added in v0.15.0
QuerySelectorAll returns a bounded static descendant snapshot.
func (*Element) RemoveAttribute ¶ added in v0.15.0
RemoveAttribute removes an element attribute and notifies the active Page once.
func (*Element) RemoveChild ¶ added in v0.14.0
RemoveChild detaches a direct child while retaining its Runtime identity.
func (*Element) RemoveClass ¶
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
RemoveInlineStyleProperty removes one declaration and returns its old value.
func (*Element) ReplaceChild ¶ added in v0.15.0
ReplaceChild replaces a direct child while preserving the removed subtree identity.
func (*Element) ReplaceChildren ¶ added in v0.14.0
ReplaceChildren atomically replaces this element's children with supplied nodes.
func (*Element) SetAttribute ¶
SetAttribute は要素の属性値を変更する。
func (*Element) SetClassName ¶ added in v0.14.0
SetClassName updates the class attribute.
func (*Element) SetIDValue ¶ added in v0.14.0
SetIDValue updates the id attribute.
func (*Element) SetInlineStyleProperty ¶ added in v0.15.0
SetInlineStyleProperty validates and updates one inline declaration.
func (*Element) SetInlineStyleText ¶ added in v0.15.0
SetInlineStyleText replaces the complete inline declaration list.
func (*Element) SetInnerHTML ¶ added in v0.14.0
SetInnerHTML parses and atomically replaces a bounded HTML fragment.
func (*Element) SetOuterHTML ¶ added in v0.15.0
SetOuterHTML replaces this element with a bounded parsed fragment.
func (*Element) TemplateContent ¶ added in v0.15.0
TemplateContent returns the detached DocumentFragment owned by a template.
func (*Element) ToggleAttribute ¶ added in v0.15.0
ToggleAttribute adds or removes a boolean attribute and returns its resulting presence.
func (*Element) ToggleClass ¶ added in v0.14.0
ToggleClass applies optional force and returns the resulting membership.
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.