Documentation
¶
Index ¶
- func CanParseURL(rawUrl string) bool
- func IsDOMError(err error) bool
- func IsInvalidCharacterError(err error) bool
- func IsNotImplementedError(err error) bool
- func IsSyntaxError(err error) bool
- func NoError[T func(U), U any](f T) func(U) error
- func SetEventTargetSelf(t EventTarget)
- type Attr
- type Attributes
- type CharacterData
- type Comment
- type CustomEvent
- type DOMError
- type DOMTokenList
- func (l DOMTokenList) Add(tokens ...string) error
- func (l DOMTokenList) All() iter.Seq[string]
- func (l DOMTokenList) Contains(token string) bool
- func (l DOMTokenList) Item(index int) *string
- func (l DOMTokenList) Length() int
- func (l DOMTokenList) Remove(token string)
- func (l DOMTokenList) Replace(oldToken string, newToken string) bool
- func (l DOMTokenList) SetValue(val string)
- func (l DOMTokenList) Toggle(token string) bool
- func (l DOMTokenList) Value() string
- type Document
- type DocumentEvent
- type DocumentFragment
- type DocumentParentWindow
- type DocumentType
- type Element
- type ElementContainer
- type ErrorEvent
- type Event
- type EventHandler
- type EventOption
- type EventOptions
- type EventTarget
- type GetRootNodeOptions
- type HandlerFunc
- type HandlerFuncWithoutError
- type Location
- type MouseEvents
- type NamedNodeMap
- type Node
- type NodeList
- type NodeType
- type NotImplementedError
- type RootNode
- type ShadowRoot
- type Text
- type URL
- func CreateObjectURL(object any) (URL, error)
- func NewURLFromNetURL(u *netURL.URL) URL
- func NewUrl(rawUrl string) (URL, error)
- func NewUrlBase(relativeUrl string, base string) (result URL, err error)
- func ParseURL(rawUrl string) URL
- func ParseURLBase(relativeUrl string, base string) URL
- func RevokeObjectURL(object any) (URL, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanParseURL ¶
func IsDOMError ¶
func IsInvalidCharacterError ¶
func IsNotImplementedError ¶
func IsSyntaxError ¶
func NoError ¶
NoError takes a function accepting a single argument and has no return value, and transforms it into a function that can be used where an error return value is expected.
func SetEventTargetSelf ¶
func SetEventTargetSelf(t EventTarget)
Types ¶
type Attr ¶
type Attr interface { Node LocalName() string Name() string NamespaceURI() string OwnerElement() Element Prefix() string Value() string SetValue(val string) // contains filtered or unexported methods }
Attr is the interface corresponding to the Attr DOM node
type Attributes ¶
type Attributes []Attr
TODO: In the DOM, this is a `NamedNodeMap`. Is that useful in Go?
func (Attributes) Length ¶
func (attrs Attributes) Length() int
type CharacterData ¶
type CustomEvent ¶
type CustomEvent interface { Event }
func NewCustomEvent ¶
func NewCustomEvent(eventType string, options ...EventOption) CustomEvent
type DOMTokenList ¶
type DOMTokenList struct {
// contains filtered or unexported fields
}
func NewClassList ¶
func NewClassList(element Element) DOMTokenList
func (DOMTokenList) Add ¶
func (l DOMTokenList) Add(tokens ...string) error
func (DOMTokenList) Contains ¶
func (l DOMTokenList) Contains(token string) bool
func (DOMTokenList) Item ¶
func (l DOMTokenList) Item(index int) *string
func (DOMTokenList) Length ¶
func (l DOMTokenList) Length() int
func (DOMTokenList) Remove ¶
func (l DOMTokenList) Remove(token string)
func (DOMTokenList) SetValue ¶
func (l DOMTokenList) SetValue(val string)
func (DOMTokenList) Toggle ¶
func (l DOMTokenList) Toggle(token string) bool
func (DOMTokenList) Value ¶
func (l DOMTokenList) Value() string
type Document ¶
type Document interface { RootNode Body() Element Head() Element CreateDocumentFragment() DocumentFragment CreateAttribute(string) Attr CreateElement(string) Element CreateElementNS(string, string) Element DocumentElement() Element Location() Location // contains filtered or unexported methods }
func NewDocument ¶
func NewDocument(window DocumentParentWindow) Document
type DocumentEvent ¶
type DocumentEvent = string
const ( DocumentEventDOMContentLoaded DocumentEvent = "DOMContentLoaded" DocumentEventLoad DocumentEvent = "load" )
type DocumentFragment ¶
type DocumentFragment interface { RootNode }
func NewDocumentFragment ¶
func NewDocumentFragment(ownerDocument Document) DocumentFragment
type DocumentParentWindow ¶
type DocumentParentWindow interface { EventTarget Location() Location Document() Document ParseFragment(ownerDocument Document, reader io.Reader) (DocumentFragment, error) }
type DocumentType ¶
func NewDocumentType ¶
func NewDocumentType(name string) DocumentType
type Element ¶
type Element interface { ElementContainer MouseEvents ClassList() DOMTokenList HasAttribute(name string) bool GetAttribute(name string) (string, bool) SetAttribute(name string, value string) GetAttributeNode(string) Attr SetAttributeNode(Attr) (Attr, error) RemoveAttributeNode(Attr) (Attr, error) Attributes() NamedNodeMap InsertAdjacentHTML(position string, text string) error OuterHTML() string InnerHTML() string TagName() string Matches(string) (bool, error) // contains filtered or unexported methods }
An Element in the document. Can be either an [HTMLElement] or an [XMLElement]
func NewElement ¶
type ElementContainer ¶
type ElementContainer interface { Node // Append supports appending multiple child elements. The JavaScript API // supports adding string values, but the Go API requires a [Text] node // explicitly for text content // // See also: https://developer.mozilla.org/en-US/docs/Web/API/Element/append Append(...Node) error QuerySelector(string) (Element, error) QuerySelectorAll(string) (staticNodeList, error) ChildElementCount() int }
ElementContainer defines common functionality in Document, DocumentFragment, and Element. While they all have Node as the direct base class in the DOM spec; they share a common set of functions operating on elements
type ErrorEvent ¶
func NewErrorEvent ¶
func NewErrorEvent(err error) ErrorEvent
type Event ¶
type Event interface { entity.Entity Cancelable() bool Bubbles() bool PreventDefault() Type() string StopPropagation() Target() EventTarget CurrentTarget() EventTarget // contains filtered or unexported methods }
func NewEvent ¶
func NewEvent(eventType string, options ...EventOption) Event
type EventHandler ¶
type EventHandler interface { // HandleEvent is called when the the event occurrs. // // An non-nil error return value will dispatch an error event on the global // object in a normally configured environment. HandleEvent(event Event) error // Equals must return true, if they underlying event handler of the other // handler is the same as this handler. Equals(other EventHandler) bool }
EventHandler is the interface for an event handler. In JavaScript; an event handler can be a function; or an object with a `handleEvent` function. In Go code, you can provide your own implementation, or use NewEventHandlerFunc to create a valid handler from a function.
Multiple EventHandler instances can represent the same underlying event handler. E.g., when JavaScript code calls RemoveEventListener, a new Go struct is created wrapping the same underlying handler.
The Equals function must return true when the other event handler is the same as the current value, so event handlers can properly be removed, and avoiding duplicates are added by AddEventListener.
func NewEventHandlerFunc ¶
func NewEventHandlerFunc(handler HandlerFunc) EventHandler
NewEventHandlerFunc creates an EventHandler implementation from a compatible function.
Note: Calling this twice for the same Go-function will be treated as different event handlers. Be sure to use the same instance returned from this function when removing.
func NewEventHandlerFuncWithoutError ¶
func NewEventHandlerFuncWithoutError(handler HandlerFuncWithoutError) EventHandler
type EventOption ¶
type EventOption interface {
// contains filtered or unexported methods
}
func EventBubbles ¶
func EventBubbles(bubbles bool) EventOption
func EventCancelable ¶
func EventCancelable(cancelable bool) EventOption
type EventOptions ¶
type EventOptions []EventOption
type EventTarget ¶
type EventTarget interface { // ObjectId is used internally for the scripting engine to associate a v8 // object with the Go object it wraps. AddEventListener(eventType string, listener EventHandler) RemoveEventListener(eventType string, listener EventHandler) DispatchEvent(event Event) bool // Adds a listener that will receive _all_ dispatched events. This listener // will not be removed from the window when navigating. This makes it useful // for a test to setup event listeners _before_ navigating, as by the time the // Navigate function returns, the DOMContentLoaded event _has_ fired, and // subscribed listeners have been called. SetCatchAllHandler(listener EventHandler) RemoveAll() // contains filtered or unexported methods }
func NewEventTarget ¶
func NewEventTarget() EventTarget
type GetRootNodeOptions ¶
type GetRootNodeOptions bool
type HandlerFunc ¶
type HandlerFuncWithoutError ¶
type HandlerFuncWithoutError = func(Event)
type Location ¶
type Location interface { URL }
Location is the interface of window.Location and document.Location (they return the same object).
The interface itself is a superset of the URL, but has setters that when set, has the side effect of the browser actually navigating.
The setters are not yet implemented, so the type is just an embedding of the URL interface
type MouseEvents ¶
type MouseEvents interface {
Click() bool
}
type NamedNodeMap ¶
type Node ¶
type Node interface { entity.Entity EventTarget AppendChild(node Node) (Node, error) GetRootNode(options ...GetRootNodeOptions) Node ChildNodes() NodeList CloneNode(deep bool) Node IsConnected() bool // IsSameNode shouldn't be used and may be removed in a future version. IsSameNode(Node) bool Contains(node Node) bool InsertBefore(newNode Node, referenceNode Node) (Node, error) NodeName() string NodeType() NodeType OwnerDocument() Document Parent() Node ParentElement() Element RemoveChild(node Node) (Node, error) NextSibling() Node PreviousSibling() Node FirstChild() Node TextContent() string SetTextContent(value string) Connected() // SetSelf must be called when creating instances of structs embedding a Node. // // If this is not called, the specialised type, which is itself a Node, will // not be returned from functions that should have returned it, e.g., through // ChildNodes. Only the embedded Node will be returned, and any specialised // behaviour, including HTML output, will not work. // // This function is a workaround to solve a fundamental problem. The DOM // specifies a model that is fundamentally object-oriented, with sub-classes // overriding behaviour in super-classes. This is not a behaviour that Go has. SetSelf(node Node) // contains filtered or unexported methods }
type NodeType ¶
type NodeType int
const ( NodeTypeElement NodeType = 1 NodeTypeAttribute NodeType = 2 NodeTypeText NodeType = 3 NodeTypeCDataSection NodeType = 4 NodeTypeProcessingInstruction NodeType = 7 NodeTypeComment NodeType = 8 NodeTypeDocument NodeType = 9 NodeTypeDocumentType NodeType = 10 NodeTypeDocumentFragment NodeType = 11 )
type NotImplementedError ¶
type NotImplementedError error
type RootNode ¶
type RootNode interface { ElementContainer GetElementById(string) Element }
RootNode implements defines common behaviour between Document and DocumentFragment. While they both have Node as the direct base class in the DOM spec; they share a common set of functions operating on elements.
type ShadowRoot ¶
type ShadowRoot interface { DocumentFragment }
type URL ¶
type URL interface { Href() string SetHref(string) Origin() string Protocol() string SetProtocol(string) Username() string SetUsername(string) Password() string SetPassword(string) Host() string SetHost(string) Hostname() string SetHostname(string) Port() string SetPort(string) Pathname() string SetPathname(string) Search() string SetSearch(string) SearchParams() string Hash() string SetHash(string) ToJSON() (string, error) }