Documentation ¶
Index ¶
- Variables
- type Attr
- type Attributes
- type Browser
- type CSSHelper
- type CustomEvent
- type Document
- type DocumentEvent
- type DocumentFragment
- type Element
- type ElementContainer
- type ElementSteps
- type Entity
- type Event
- type EventHandler
- type EventTarget
- type HTMLElement
- type HandlerFunc
- type HandlerFuncWithoutError
- type HandlerRoundTripper
- type Location
- type NamedNodeMap
- type Node
- type NodeHelper
- type NodeIterator
- type NodeType
- type ObjectId
- type RootNode
- type RootNodeHelper
- type ScriptElementRules
- type ScriptEngine
- type ScriptEngineFactory
- type ShadowRoot
- type StaticNodeList
- type TextNode
- type Window
Constants ¶
This section is empty.
Variables ¶
var ElementMap = map[atom.Atom]ElementSteps{ atom.Script: ScriptElementRules{}, }
Functions ¶
This section is empty.
Types ¶
type Attributes ¶
TODO: In the DOM, this is a `NamedNodeMap`. Is that useful in Go?
func (Attributes) Length ¶
func (attrs Attributes) Length() int
type Browser ¶
type Browser struct { Client http.Client ScriptEngine ScriptEngine ScriptEngineFactory ScriptEngineFactory }
Pretty stupid right now, but should _probably_ allow handling multiple windows/tabs. Particularly if testing login flow; where the login
func NewBrowserFromHandler ¶
type CSSHelper ¶
type CSSHelper struct{ Node }
func (CSSHelper) QuerySelectorAll ¶
func (d CSSHelper) QuerySelectorAll(pattern string) (StaticNodeList, error)
type CustomEvent ¶
type CustomEvent interface { Event }
func NewCustomEvent ¶
func NewCustomEvent(eventType string) CustomEvent
type Document ¶
type Document interface { RootNode Body() Element Head() Element CreateDocumentFragment() DocumentFragment CreateElement(string) Element DocumentElement() Element // contains filtered or unexported methods }
func NewDocument ¶
func NewDocument() Document
func ParseHtmlStream ¶
func ParseHtmlString ¶
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 Element ¶
type Element interface { ElementContainer Append(Element) Element GetAttribute(name string) string SetAttribute(name string, value string) GetAttributes() NamedNodeMap InsertAdjacentHTML(position string, text string) error OuterHTML() string TagName() string // 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(Element) Element QuerySelector(string) (Node, error) QuerySelectorAll(string) (StaticNodeList, error) }
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 ElementSteps ¶
type EventHandler ¶
type EventHandler interface { HandleEvent(event Event) error // The interface for removing event handlers requires the caller to pass in // the same handler to `RemoveEventListener`. In Go; functions cannot be // compared for equality; so we need to have some kind of mechanism to // identify if two handlers are identical. 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.
Duplicate detection during _add_, or removal is based on equality. JavaScript equality does not translate natively to Go, so a handler must be able to detect equality by itself
func NewEventHandlerFunc ¶
func NewEventHandlerFunc(handler HandlerFunc) EventHandler
NewEventHandlerFunc creates an EventHandler wrapping a function with the right signature. Calling this twice for the same Go-function will be treated as different event handlers; as Go functions do not support equality.
func NewEventHandlerFuncWithoutError ¶
func NewEventHandlerFuncWithoutError(handler HandlerFuncWithoutError) EventHandler
type EventTarget ¶
type EventTarget interface { // ObjectId is used internally for the scripting engine to associate a v8 // object with the Go object it wraps. ObjectId() ObjectId AddEventListener(eventType string, listener EventHandler) RemoveEventListener(eventType string, listener EventHandler) DispatchEvent(event Event) error }
func NewEventTarget ¶
func NewEventTarget() EventTarget
type HTMLElement ¶
type HTMLElement interface { Element }
type HandlerFunc ¶
type HandlerFuncWithoutError ¶
type HandlerFuncWithoutError = func(Event)
type HandlerRoundTripper ¶
type Location ¶
type Location interface { GetHash() string GetHost() string GetHostname() string GetHref() string // TODO // SetHref(href string) GetOrigin() string GetPathname() string GetPort() string GetProtocol() string GetSearch() string }
func NewLocation ¶
type NamedNodeMap ¶
func NewNamedNodeMapForElement ¶
func NewNamedNodeMapForElement(ownerElement Element) NamedNodeMap
type Node ¶
type Node interface { EventTarget AppendChild(node Node) Node ChildNodes() []Node Connected() bool InsertBefore(newNode Node, referenceNode Node) (Node, error) NodeName() string NodeType() NodeType OwnerDocument() Document // TODO: Element, not Node Parent() Node RemoveChild(node Node) error NextSibling() Node // contains filtered or unexported methods }
type NodeHelper ¶
type NodeHelper struct{ Node }
func (NodeHelper) AppendChild ¶
func (n NodeHelper) AppendChild(child Node) Node
func (NodeHelper) InsertBefore ¶
func (n NodeHelper) InsertBefore(newChild Node, referenceNode Node) (Node, error)
type NodeIterator ¶
type NodeIterator struct{ Node }
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 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 RootNodeHelper ¶
type RootNodeHelper struct{ RootNode }
func (RootNodeHelper) GetElementById ¶
func (d RootNodeHelper) GetElementById(id string) Element
type ScriptElementRules ¶
type ScriptElementRules struct{}
func (ScriptElementRules) Connected ¶
func (r ScriptElementRules) Connected(win Window, node Element)
type ScriptEngine ¶
type ScriptEngineFactory ¶
type ScriptEngineFactory interface {
NewScriptEngine(window Window) ScriptEngine
}
type ShadowRoot ¶
type ShadowRoot interface { DocumentFragment }
type StaticNodeList ¶
type StaticNodeList []Node