gom

package module
v0.0.0-...-50eeb40 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: MIT Imports: 4 Imported by: 0

README ¶

GOM

The GOM library is a light implementation of the DOM tree. It implements the very basic to be able to build a DOM tree without the "useless" of DOM standard like documentURI that are useful for the web.

Contributing

If you want to contribute to GOM to add a feature or improve the code contact me at alexnegrel13@gmail.com, open an issue or make a pull request.

📜 License

MIT © Alexandre Negrel

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	DocumentPositionDisconnected = 1 << iota
	DocumentPositionPreceding
	DocumentPositionFollowing
	DocumentPositionContains
	DocumentPositionContainedBy
	DocumentPositionImplementationSpecific
)

The CompareDocumentPosition return values are a bitmask with the following values.

View Source
const (
	ElementNode
	AttributeNode
	TextNode
	CommentNode
	DocumentNode
	DocumentTypeNode
)

Node type list

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type Attr ¶

type Attr interface {
	/* EMBEDDED INTERFACE */
	Node
	/* GETTERS & SETTERS (props) */
	Name() string
	OwnerElement() Element
	Value() string
	SetValue(string)
}

Attr interface represents one of a DOM element's attributes as an object. https://developer.mozilla.org/en-US/docs/Web/API/Attr https://dom.spec.whatwg.org/#attr

type CharacterData ¶

type CharacterData interface {
	/* EMBEDDED INTERFACE */
	Node
	NonDocumentTypeChildNode
	/* GETTERS & SETTERS (props) */
	Data() string
	Length() int
	SetData(string)
	/* METHODS */
	AppendData(string) string
	DeleteData(uint, uint) string
	InsertData(uint, string) string
	ReplaceData(uint, uint, string)
	SubstringData(uint, uint) string
}

The CharacterData abstract interface represents a Node object that contains characters. https://developer.mozilla.org/en-US/docs/Web/API/CharacterData https://dom.spec.whatwg.org/#interface-characterdata

type Document ¶

type Document interface {
	Node
	/* GETTERS & SETTERS (props) */
	Body() Node
	CharacterSet() encoding.Encoding
	DocType() DocumentType
	DocumentElement() Element
	Head() Element
	Hidden() bool
	SetBody(Node)
	SetCharacterSet(encoding.Encoding)
	/* METHODS */
	AdoptNode(Node)
	CreateAttribute(string) Attr
	CreateComment() Node
	CreateDocumentFragment() DocumentFragment
	CreateElement(string) Element
	CreateTextNode() Node
	GetElementsByClassName(string) Element
	GetElementsByTagName(string) Element
	ImportNode(Node, bool) Node
	GetElementById(string) Element
	QuerySelector(string) Element
	QuerySelectorAll(string) NodeList
}

Document interface represents any page loaded and serves as an entry point into the page's content https://developer.mozilla.org/en-US/docs/Web/API/Document https://dom.spec.whatwg.org/#document

func NewDocument ¶

func NewDocument(name string) Document

NewDocument return a new document object serving as an entry point into the page's content.

type DocumentFragment ¶

type DocumentFragment interface {
	/* EMBEDDED INTERFACE */
	Node
}

DocumentFragment object represents a minimal document object that has no parent https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment https://dom.spec.whatwg.org/#documentfragment

type DocumentType ¶

type DocumentType interface {

	/* EMBEDDED INTERFACE */
	Node
	/* GETTERS & SETTERS (props) */
	Name() string
	PublicId() string
	SystemId() string
	// contains filtered or unexported methods
}

DocumentType represent a node containing a doctype. https://developer.mozilla.org/en-US/docs/Web/API/documentType https://dom.spec.whatwg.org/#documentType

type Element ¶

type Element interface {
	/* EMBEDDED INTERFACE */
	Node
	NonDocumentTypeChildNode
	/* GETTERS & SETTERS (props) */
	Attributes() NamedNodeMap
	ClassList() []string
	ClassName() string
	ClientHeight() int
	ClientWidth() int
	Id() Attr
	InnerGOML() string
	OuterGOML() string
	ScrollHeight() int
	ScrollLeft() int
	ScrollTop() int
	ScrollWidth() int
	SetClassName(string)
	SetInnerGOML(string)
	SetOuterGOML(string)
	SetScrollTop(int)
	SetScrollLeft(int)
	TagName() string
	/* METHODS */
	GetAttribute(string) Attr
	GetAttributeNames() []string
	GetBoundingClientRect() GOMRect
	GetClientRects() []GOMRect
	GetElementsByClassName(string) GOMLCollection
	GetElementsByTagName(string) GOMLCollection
	HasAttribute(string) bool
	QuerySelector(string) Node
	QuerySelectorAll(string) NodeList
	RemoveAttribute(string)
	Scroll(x, y int)
	ScrollBy(x, y int)
	ScrollTo(x, y int)
	SetAttribute(name string, value interface{})
	ToggleAttribute(string)
}

Element is most general base class from which all objects in a Document inherit. Element is not destined to be instancied but to be embedded. https://developer.mozilla.org/en-US/docs/Web/API/Element https://dom.spec.whatwg.org/#interface-element

type GOMLCollection ¶

type GOMLCollection interface {
	/* GETTERS & SETTERS (props) */
	Length() int
	/* METHODS */
	Item(int) Element
}

GOMLCollection is live collection of elements https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection https://dom.spec.whatwg.org/#htmlcollection

type GOMLDocument ¶

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

GOMLDocument is a light HTMLDocument used for non-web document.

func (*GOMLDocument) AdoptNode ¶

func (d *GOMLDocument) AdoptNode(external Node)

AdoptNode transfers a node from another document into the document on which the method was called. https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptNode

func (*GOMLDocument) Body ¶

func (d *GOMLDocument) Body() Node

Body return the <body> element of the current document https://developer.mozilla.org/en-US/docs/Web/API/Document/body

func (*GOMLDocument) CharacterSet ¶

func (d *GOMLDocument) CharacterSet() encoding.Encoding

CharacterSet return the current character set used by the document. https://developer.mozilla.org/en-US/docs/Web/API/Document/characterSet

func (*GOMLDocument) CreateAttribute ¶

func (d *GOMLDocument) CreateAttribute(name string) Attr

CreateAttribute method creates a new attribute node, and returns it. https://developer.mozilla.org/en-US/docs/Web/API/Document/createAttribute

func (*GOMLDocument) CreateComment ¶

func (d *GOMLDocument) CreateComment() Node

CreateComment creates a new comment node, and returns it. https://developer.mozilla.org/en-US/docs/Web/API/Document/createComment

func (*GOMLDocument) CreateDocumentFragment ¶

func (d *GOMLDocument) CreateDocumentFragment() DocumentFragment

CreateDocumentFragment creates a new comment node, and returns it. https://developer.mozilla.org/en-US/docs/Web/API/Document/createDocumentFragment

func (*GOMLDocument) CreateElement ¶

func (d *GOMLDocument) CreateElement(tagName string) Element

CreateElement creates a new comment node, and returns it. https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

func (*GOMLDocument) CreateTextNode ¶

func (d *GOMLDocument) CreateTextNode(content string) Text

CreateTextNode creates a new comment node, and returns it. https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode

func (*GOMLDocument) DocType ¶

func (d *GOMLDocument) DocType() DocumentType

DocType returns the Document Type Declaration (DTD) associated with current document. https://developer.mozilla.org/en-US/docs/Web/API/Document/doctype

func (*GOMLDocument) DocumentElement ¶

func (d *GOMLDocument) DocumentElement() Element

DocumentElement returns the Element that is the root element of the document. https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement

func (*GOMLDocument) GetElementById ¶

func (d *GOMLDocument) GetElementById(id string) Element

GetElementById returns an Element object representing the element whose id property matches the specified string https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById

func (*GOMLDocument) GetElementsByClassName ¶

func (d *GOMLDocument) GetElementsByClassName(className string) Element

GetElementsByClassName method of Document interface returns an array-like object of all child elements which have all of the given class names. https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName

func (*GOMLDocument) GetElementsByTagName ¶

func (d *GOMLDocument) GetElementsByTagName(tagName string) Element

GetElementsByTagName method of Document interface returns an array-like object of all child elements which have all of the given tag names. https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByTagName

func (*GOMLDocument) Head ¶

func (d *GOMLDocument) Head() Element

Head return the <head> element of the current document https://developer.mozilla.org/en-US/docs/Web/API/Document/head

func (*GOMLDocument) Hidden ¶

func (d *GOMLDocument) Hidden() bool

Hidden returns a Boolean value indicating if the page is considered hidden or not. https://developer.mozilla.org/en-US/docs/Web/API/Document/hidden

func (*GOMLDocument) ImportNode ¶

func (d *GOMLDocument) ImportNode(node Node, deep bool) Node

ImportNode method creates a copy of a Node or DocumentFragment from another document, to be inserted into the current document later. https://developer.mozilla.org/en-US/docs/Web/API/Document/importNode

func (*GOMLDocument) NodeName ¶

func (d *GOMLDocument) NodeName() string

NodeName return the GOML-uppercased name

func (*GOMLDocument) NodeType ¶

func (d *GOMLDocument) NodeType() NodeType

NodeType return the "ElementNode" type.

func (*GOMLDocument) QuerySelector ¶

func (d *GOMLDocument) QuerySelector(selector string) Element

QuerySelector returns the first Element within the document that matches the specified selector, or group of selectors. https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector

func (*GOMLDocument) QuerySelectorAll ¶

func (d *GOMLDocument) QuerySelectorAll(selector string) NodeList

QuerySelectorAll returns a static (not live) NodeList representing a list of the document's elements that match the specified group of selectors. https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll

func (*GOMLDocument) SetBody ¶

func (d *GOMLDocument) SetBody(body Node)

SetBody set the body node of the document. https://developer.mozilla.org/en-US/docs/Web/API/Document/body

func (*GOMLDocument) SetCharacterSet ¶

func (d *GOMLDocument) SetCharacterSet(charSet encoding.Encoding)

SetCharacterSet method set the document character set (UTF-8). https://developer.mozilla.org/en-US/docs/Web/API/Document/characterSet

type GOMLElement ¶

type GOMLElement interface {
	/* EMBEDDED INTERFACE */
	Element
	/* GETTERS & SETTERS (props) */
	Hidden() bool
	InnerText() string
	SetInnerText(string)
	Style() interface{}
	/* METHODS */
	Click()
}

GOMLElement interface represents any GOML element

type GOMLSpanElement ¶

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

GOMLSpanElement define a <span> element and embbed the GOMLElement.

func (*GOMLSpanElement) Click ¶

func (e *GOMLSpanElement) Click()

Click handle click event a GOML element.

func (*GOMLSpanElement) Hidden ¶

func (e *GOMLSpanElement) Hidden() bool

Hidden return true if the element is hidden or not. https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/hidden

func (*GOMLSpanElement) InnerText ¶

func (e *GOMLSpanElement) InnerText() string

InnerText represents the "rendered" text content of a node and its descendants. https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText

func (*GOMLSpanElement) ScrollHeight ¶

func (s *GOMLSpanElement) ScrollHeight() int

ScrollHeight return always 0 for a span element https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight

func (*GOMLSpanElement) ScrollLeft ¶

func (s *GOMLSpanElement) ScrollLeft() int

ScrollLeft return always 0 for a span element https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft

func (*GOMLSpanElement) ScrollTop ¶

func (s *GOMLSpanElement) ScrollTop() int

ScrollTop return always 0 for a span element https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop

func (*GOMLSpanElement) ScrollWidth ¶

func (s *GOMLSpanElement) ScrollWidth() int

ScrollWidth return always 0 for a span element https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth

func (*GOMLSpanElement) SetInnerText ¶

func (e *GOMLSpanElement) SetInnerText(string)

SetInnerText set the inner text of a GOML element. https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText

func (*GOMLSpanElement) Style ¶

func (e *GOMLSpanElement) Style() interface{}

Style return

func (*GOMLSpanElement) TagName ¶

func (s *GOMLSpanElement) TagName() string

TagName returns the tag name of the element on which it's called. https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName

type GOMRect ¶

type GOMRect interface {
	/* GETTERS & SETTERS (props) */
	X() int
	Y() int
	Width() int
	Height() int
	Top() int
	Right() int
	Bottom() int
	Left() int
}

GOMRect represents a rectangle.

type NamedNodeMap ¶

type NamedNodeMap interface {

	/* GETTERS & SETTERS (props) */
	Length() int
	/* METHODS */
	GetNamedItem(string) Attr
	Item(int) Attr
	SetNamedItem(Attr)
	RemoveNamedItem(string) (Attr, e.Exception)
	Values() []Attr // Not part of DOM specification
	// contains filtered or unexported methods
}

NamedNodeMap interface represents a collection of Attr objects. https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap https://dom.spec.whatwg.org/#interface-namednodemap

type Node ¶

type Node interface {

	/* GETTERS & SETTERS (props) */
	ChildNodes() NodeList
	FirstChild() Node
	LastChild() Node
	NextSibling() Node
	NodeName() string
	NodeType() NodeType
	OwnerDocument() Document
	ParentNode() Node
	ParentElement() Element
	PreviousSibling() Node
	TextContent() string
	SetOwnerDocument(doc Document)
	SetTextContent(content string)
	/* METHODS */
	AppendChild(child Node) Node
	CloneNode(deep bool) Node
	CompareDocumentPosition(other Node) int
	Contains(other Node) bool
	GetRootNode() Node
	HasChildNodes() bool
	InsertBefore(new, reference Node) Node
	IsEqualNode(other Node) bool
	IsSameNode(other Node) bool
	Normalize()
	RemoveChild(child Node) (Node, e.Exception)
	ReplaceChild(newChild, oldChild Node) e.Exception
	// contains filtered or unexported methods
}

Node is an interface and does not exist as node (abstract). It is used embedded by all nodes. (Document, DocumentType, Element, Text, and Comment). https://developer.mozilla.org/en-US/docs/Web/API/Node https://dom.spec.whatwg.org/#node

type NodeList ¶

type NodeList interface {

	/* GETTERS & SETTERS */
	Length() int
	/* METHODS */
	ForEach(func(i int, c Node))
	IndexOf(n Node) int
	Item(index int) Node
	Values() []Node
	// contains filtered or unexported methods
}

NodeList objects are collections of nodes (live) https://developer.mozilla.org/en-US/docs/Web/API/NodeList

type NodeType ¶

type NodeType = uint32

NodeType is the type of a Node.

type NonDocumentTypeChildNode ¶

type NonDocumentTypeChildNode interface {
	/* GETTERS & SETTERS (props) */
	PreviousElementSibling() Element
	NextElementSibling() Element
}

NonDocumentTypeChildNode interface contains methods that are particular to Node objects that can have a parent, but not suitable for DocumentType. https://developer.mozilla.org/en-US/docs/Web/API/NonDocumentTypeChildNode https://dom.spec.whatwg.org/#interface-nondocumenttypechildnode

type ParentNode ¶

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

ParentNode mixin contains methods and properties that are common to all types of Node objects that can have children https://developer.mozilla.org/en-US/docs/Web/API/ParentNode https://dom.spec.whatwg.org/#parentnode

func (*ParentNode) Append ¶

func (pn *ParentNode) Append()

Append inserts a set of Node objects or DOMString objects after the last child of the ParentNode https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append

func (*ParentNode) FirstElementChild ¶

func (pn *ParentNode) FirstElementChild() Element

FirstElementChild returns the object's first child Element, or null if there are no child elements. https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/firstElementChild

func (*ParentNode) LastElementChild ¶

func (pn *ParentNode) LastElementChild() Element

LastElementChild returns the object's last child Element, or null if there are no child elements. https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/lastElementChild

func (*ParentNode) Prepend ¶

func (pn *ParentNode) Prepend(nodes ...Node)

Prepend inserts a set of Node objects or DOMString objects before the first child of the ParentNode https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/prepend

func (*ParentNode) QuerySelector ¶

func (pn *ParentNode) QuerySelector(selector string)

QuerySelector returns the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned. https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector

func (*ParentNode) QuerySelectorAll ¶

func (pn *ParentNode) QuerySelectorAll(selector string)

QuerySelectorAll returns a static (not live) NodeList representing a list of the document's elements that match the specified group of selectors. https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll

type Text ¶

type Text interface {
	/* EMBEDDED INTERFACE */
	CharacterData
	/* GETTERS & SETTERS (props) */
	WholeText() string
	/* METHODS */
	SplitText(uint) (Text, exception.Exception)
}

Text interface represents the textual content of Element or Attr. https://developer.mozilla.org/en-US/docs/Web/API/Text https://dom.spec.whatwg.org/#interface-text

Directories ¶

Path Synopsis

Jump to

Keyboard shortcuts

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