dom

package
v0.1.6-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	UNDEFINED_NODE string = "<undefined node>"
	UNDEFINED_ATTR string = "<undefined attribute>"
)

Variables

This section is empty.

Functions

func WrapId

func WrapId(ui UIComposer, id string) (*Element, UIComposer)

WrapId looks for elemid into the DOM and wrap it to ui if its type corresponds to the attribute name of the element. Returns ui to allow chaining calls.

If elemid is not in the DOM or if the type does not match or if ui does not implement, a message is logged out if verbose mode is on.

Types

type DOC_READYSTATE

type DOC_READYSTATE string

https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState

const (
	DOC_READY       DOC_READYSTATE = "loading"
	DOC_INTERACTIVE DOC_READYSTATE = "interactive"
	DOC_COMPLETE    DOC_READYSTATE = "complete"
)

type DOC_VISIBILITYSTATE

type DOC_VISIBILITYSTATE string

The Document.visibilityState returns the visibility of the document, that is in which context this element is now visible. It is useful to know if the document is in the background or an invisible tab, or only loaded for pre-rendering.

https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState

const (
	DOC_HIDDEN    DOC_VISIBILITYSTATE = "hidden"
	DOC_VISIBLE   DOC_VISIBILITYSTATE = "visible"
	DOC_PRERENDER DOC_VISIBILITYSTATE = "prerender"
)

type Document

type Document struct {
	Node
}

Document represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.

The Document describes the common properties and methods for any kind of document. Depending on the document's type (e.g. HTML, XML, SVG, …), a larger API is available: HTML documents, served with the "text/html" content type, also implement the HTMLDocument interface, whereas XML and SVG documents implement the XMLDocument interface.

func CastDocument

func CastDocument(_jsv js.JSValueProvider) *Document

CastDocument is casting a js.Value into Document.

func Doc

func Doc() Document

GetDocument returns the current document within the current window

func (*Document) AddEventResize

func (_doc *Document) AddEventResize(_listener func(*event.UIEvent, *Document))

AddResize is adding doing AddEventListener for 'Resize' on target. This method is returning allocated javascript function that need to be released.

func (*Document) AddEventWheel

func (_doc *Document) AddEventWheel(_listener func(*event.WheelEvent, *Document))

AddWheel is adding doing AddEventListener for 'Wheel' on target. This method is returning allocated javascript function that need to be released.

func (*Document) AddFocusEvent

func (_doc *Document) AddFocusEvent(_evttyp event.FOCUS_EVENT, _listener func(*event.FocusEvent, *Document))

func (*Document) AddFullscreenEvent

func (_doc *Document) AddFullscreenEvent(_evttyp event.FULLSCREEN_EVENT, _listener func(*event.Event, *Document))

AddFullscreenChange is adding doing AddEventListener for 'FullscreenChange' on target. This method is returning allocated javascript function that need to be released.

func (*Document) AddGenericEvent

func (_doc *Document) AddGenericEvent(_evttyp event.GENERIC_EVENT, _listener func(*event.Event, *Document))

func (*Document) AddInputEvent

func (_doc *Document) AddInputEvent(_evttyp event.INPUT_EVENT, _listener func(*event.InputEvent, *Document))

func (*Document) AddKeyboardEvent

func (_doc *Document) AddKeyboardEvent(_evttyp event.KEYBOARD_EVENT, _listener func(*event.KeyboardEvent, *Document))

func (*Document) AddMouseEvent

func (_doc *Document) AddMouseEvent(_evttyp event.MOUSE_EVENT, _listener func(*event.MouseEvent, *Document))

func (*Document) AddPointerEvent

func (_doc *Document) AddPointerEvent(_evttyp event.POINTER_EVENT, _listener func(*event.PointerEvent, *Document))

func (*Document) AppendNodes

func (_doc *Document) AppendNodes(nodes []*Node)

Append inserts a set of Node objects or string objects after the last child of the document. String objects are inserted as equivalent Text nodes.

https://developer.mozilla.org/en-US/docs/Web/API/Document/append

func (*Document) AppendStrings

func (_doc *Document) AppendStrings(strs []string)

Append inserts a set of Node objects or string objects after the last child of the document. String objects are inserted as equivalent Text nodes.

https://developer.mozilla.org/en-US/docs/Web/API/Document/append

func (Document) Body

func (_doc Document) Body() *Element

The Document.body property represents the <body> or <frameset> node of the current document, or null if no such element exists.

https://developer.mozilla.org/en-US/docs/Web/API/Document/body

func (Document) CharacterSet

func (_doc Document) CharacterSet() string

CharacterSet returns the character encoding of the document that it's currently rendered with.

https://developer.mozilla.org/en-US/docs/Web/API/Document/characterSet

func (Document) ChildAtPoint

func (_doc Document) ChildAtPoint(x float64, y float64) *Element

GetElementAtPoint returns the topmost Element at the specified coordinates (relative to the viewport).

https://developer.mozilla.org/en-US/docs/Web/API/Document/elementFromPoint

func (Document) ChildById

func (doc Document) ChildById(elementId string) *Element

ChildById calls GetElementById and returns an Element object representing the element whose id property matches the specified string. Since element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly. If the id is not found, returns an undefined element, not nil

https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById

func (Document) ChildrenAtPoint

func (_doc Document) ChildrenAtPoint(x float64, y float64) (_result []*Element)

GetElementsAtPoint eturns an array of all elements at the specified coordinates (relative to the viewport). The elements are ordered from the topmost to the bottommost box of the viewport.

https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint

func (Document) ChildrenByClassName

func (_doc Document) ChildrenByClassName(classNames string) []*Element

GetElementsByClassName returns an array-like object of all child elements which have all of the given class name(s).

https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName

func (Document) ChildrenByName

func (_doc Document) ChildrenByName(elementName string) []*Element

GetElementsByName returns a NodeList Collection of elements with a given name attribute in the document.

https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByName

func (Document) ChildrenByTagName

func (_doc Document) ChildrenByTagName(qualifiedName string) []*Element

GetElementsByTagName returns an HTMLCollection of elements with the given tag name.

https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByTagName

func (Document) ChildrenCount

func (_doc Document) ChildrenCount() int

ChildElementCount returns the number of child elements of the document.

https://developer.mozilla.org/en-US/docs/Web/API/Document/childElementCount

func (Document) CompatMode

func (_doc Document) CompatMode() string

CompatMode ndicates whether the document is rendered in Quirks mode or Standards mode.

https://developer.mozilla.org/en-US/docs/Web/API/Document/compatMode

func (Document) ContentType

func (_doc Document) ContentType() string

ContentType returns the MIME type that the document is being rendered as. This may come from HTTP headers or other sources of MIME information, and might be affected by automatic type conversions performed by either the browser or extensions.

https://developer.mozilla.org/en-US/docs/Web/API/Document/contentType

func (Document) Cookie

func (_doc Document) Cookie() string

Cookie lets you read and write cookies associated with the document. It serves as a getter and setter for the actual values of the cookies.

https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie

func (Document) DesignMode

func (_doc Document) DesignMode() string

DesignMode controls whether the entire document is editable. Valid values are "on" and "off". According to the specification, this property is meant to default to "off". Firefox follows this standard. The earlier versions of Chrome and IE default to "inherit". Starting in Chrome 43, the default is "off" and "inherit" is no longer supported. In IE6-10, the value is capitalized.

https://developer.mozilla.org/en-US/docs/Web/API/Document/designMode

func (Document) DocTypeName

func (_doc Document) DocTypeName() string

Doctype Name, The type of the document. It is always "html" for HTML documents, but will vary for XML documents.

https://developer.mozilla.org/en-US/docs/Web/API/Document/doctype

func (Document) DocTypePublicId

func (_doc Document) DocTypePublicId() string

A string with an identifier of the type of document. Always empty ("") for HTML, it will be, for example, "-//W3C//DTD SVG 1.1//EN" for SVG documents.

https://developer.mozilla.org/en-US/docs/Web/API/Document/doctype

func (Document) DocTypeSystemId

func (_doc Document) DocTypeSystemId() string

A string containing the URL to the associated DTD. Always empty ("") for HTML, it will be, for example, "http://www.w3.org/2000/svg" for SVG documents.

https://developer.mozilla.org/en-US/docs/Web/API/Document/doctype

func (Document) FocusedElement

func (_doc Document) FocusedElement() *Element

ActiveElement returns the Element within the DOM that currently has focus.

https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement

func (Document) FullscreenElement

func (_doc Document) FullscreenElement() *Element

FullscreenElement returns the Element that is currently being presented in fullscreen mode in this document, or null if fullscreen mode is not currently in use.

https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenElement

func (Document) HasFocus

func (_doc Document) HasFocus() bool

HasFocus returns a boolean value indicating whether the document or any element inside the document has focus. This method can be used to determine whether the active element in a document has focus.

https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus

func (Document) Head

func (_doc Document) Head() *Element

Head returns the <head> element of the current document.

https://developer.mozilla.org/en-US/docs/Web/API/Document/head

func (Document) Hidden

func (_doc Document) 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 (Document) IsInDOM

func (doc Document) IsInDOM(elemid string) bool

IsInDOM return true if the element has been found in the DOM.

func (Document) LastModified

func (_doc Document) LastModified() time.Time

LastModified returns a string containing the date and time on which the current document was last modified.

TODO: dom - test Document.LastModified

https://developer.mozilla.org/en-US/docs/Web/API/Document/lastModified

func (*Document) PrepenStrings

func (_doc *Document) PrepenStrings(strs []string)

Prepend inserts a set of Node objects or string objects before the first child of the document. String objects are inserted as equivalent Text nodes.

https://developer.mozilla.org/en-US/docs/Web/API/Document/prepend

func (*Document) PrependNodes

func (_doc *Document) PrependNodes(nodes []*Node)

Prepend inserts a set of Node objects or string objects before the first child of the document. String objects are inserted as equivalent Text nodes.

https://developer.mozilla.org/en-US/docs/Web/API/Document/prepend

func (Document) ReadyState

func (_doc Document) ReadyState() DOC_READYSTATE

ReadyState describes the loading state of the document. When the value of this property changes, a readystatechange event fires on the document object.

https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState

func (Document) Referrer

func (_doc Document) Referrer() *url.URL

Referrer returns the URI of the page that linked to this page.

https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer

func (Document) RootElement

func (_doc Document) RootElement() *Element

DocumentElement returns the Element that is the root element of the document (for example, the <html> element for HTML documents).

https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement

func (Document) SelectorQueryAll

func (_doc Document) SelectorQueryAll(selectors string) []*Element

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 (Document) SelectorQueryFirst

func (_doc Document) SelectorQueryFirst(selectors string) *Element

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 (*Document) SetBody

func (_doc *Document) SetBody(value *Element) *Document

The Document.body property represents the <body> or <frameset> node of the current document, or null if no such element exists.

https://developer.mozilla.org/en-US/docs/Web/API/Document/body

func (*Document) SetCookie

func (_doc *Document) SetCookie(value string) *Document

Cookie lets you read and write cookies associated with the document. It serves as a getter and setter for the actual values of the cookies.

https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie

func (*Document) SetDesignMode

func (_doc *Document) SetDesignMode(value string) *Document

DesignMode controls whether the entire document is editable. Valid values are "on" and "off". According to the specification, this property is meant to default to "off". Firefox follows this standard. The earlier versions of Chrome and IE default to "inherit". Starting in Chrome 43, the default is "off" and "inherit" is no longer supported. In IE6-10, the value is capitalized.

https://developer.mozilla.org/en-US/docs/Web/API/Document/designMode

func (*Document) SetTitle

func (_doc *Document) SetTitle(value string) *Document

Title gets or sets the current title of the document. When present, it defaults to the value of the <title>.

https://developer.mozilla.org/en-US/docs/Web/API/Document/title

func (Document) Title

func (_doc Document) Title() string

Title gets or sets the current title of the document. When present, it defaults to the value of the <title>.

https://developer.mozilla.org/en-US/docs/Web/API/Document/title

func (Document) VisibilityState

func (_doc Document) VisibilityState() DOC_VISIBILITYSTATE

VisibilityState returns the visibility of the document, that is in which context this element is now visible. It is useful to know if the document is in the background or an invisible tab, or only loaded for pre-rendering.

https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState

type Element

type Element struct {
	Node
}

Element is the most general base class from which all element objects (i.e. objects that represent elements) in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element.

https://developer.mozilla.org/en-US/docs/Web/API/Element

func CastElement

func CastElement(_jsv js.JSValueProvider) *Element

CastElement is casting a js.Value into Element.

func CastElements

func CastElements(_jsvp js.JSValueProvider) []*Element

func CreateElement

func CreateElement(tagName string) *Element

CreateElement creates the HTML element specified by tagName, or an HTMLUnknownElement if tagName isn't recognized.

https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

func Id

func Id(elementid string) *Element

Id returns the Element found in the doc with the _elementId attribute. Returns an undefined Element if the id is not found, never nil.

func MountId

func MountId(ui UIComposer, id string) *Element

MountId wraps the id to the uicomposer and add its listeners and to it and to all its childs. Returns wrapped element

func TryCastId

func TryCastId(ui UIComposer, id string) (*Element, error)

func TryMountId

func TryMountId(ui UIComposer, id string) (*Element, error)

TryMountId wraps the elemid to the uicomposer and add its listeners and to it and to all its childs. Returns wrapping errors.

func TryWrapId

func TryWrapId(ui UIComposer, id string) (*Element, error)

TryWrapId looks for elemid into the DOM and wrap it to ui if its type corresponds to the attribute name of the element. Returns an error if elemid is not in the DOM or if the type does not match or ui ick does not implement .

func (*Element) AccessKey

func (elem *Element) AccessKey() string

AccessKey A string indicating the single-character keyboard key to give access to the button.

func (*Element) AddClass

func (elem *Element) AddClass(lists ...string) *Element

AddClass adds each class in lists strings to the class attribute. Each lists class string can be either a single class or a string of multiple classes separated by spaces. Duplicates are not inserted twice.

func (*Element) AddClassIf

func (elem *Element) AddClassIf(condition bool, addlist ...string) *Element

AddClassIf adds each c classe to the class attribute if the condition is true. Does nothing if the condition is false. See SetClassIf to also remove the class if the condition is false.

func (*Element) AddFocusEvent

func (_htmle *Element) AddFocusEvent(_evttyp event.FOCUS_EVENT, listener func(*event.FocusEvent, *Element))

AddBlur is adding doing AddEventListener for 'Blur' on target. This method is returning allocated javascript function that need to be released.

func (*Element) AddFullscreenEvent

func (elem *Element) AddFullscreenEvent(_evttyp event.FULLSCREEN_EVENT, _listener func(*event.Event, *Element))

AddFullscreenChange is adding doing AddEventListener for 'FullscreenChange' on target. This method is returning allocated javascript function that need to be released.

func (*Element) AddGenericEvent

func (_htmle *Element) AddGenericEvent(_evttyp event.GENERIC_EVENT, _listener func(*event.Event, *Element))

AddGenericEvent adds Event Listener for a GENERIC_EVENT on target. Returns the function to call to remove and release the listener

func (*Element) AddInputEvent

func (_htmle *Element) AddInputEvent(_evttyp event.INPUT_EVENT, listener func(*event.InputEvent, *Element))

AddInput is adding doing AddEventListener for 'Input' on target. This method is returning allocated javascript function that need to be released.

func (*Element) AddKeyboard

func (_htmle *Element) AddKeyboard(_evttyp event.KEYBOARD_EVENT, listener func(*event.KeyboardEvent, *Element))

AddKeyDown is adding doing AddEventListener for 'KeyDown' on target. This method is returning allocated javascript function that need to be released.

func (*Element) AddMouseEvent

func (_htmle *Element) AddMouseEvent(_evttyp event.MOUSE_EVENT, listener func(*event.MouseEvent, *Element))

AddClick adds Event Listener for MOUSE_EVENT on target. Returns the function to call to remove and release the listener

func (*Element) AddPointerEvent

func (_htmle *Element) AddPointerEvent(_evttyp event.POINTER_EVENT, _listener func(*event.PointerEvent, *Element))

AddGotPointerCapture is adding doing AddEventListener for 'GotPointerCapture' on target. This method is returning allocated javascript function that need to be released.

func (*Element) AddResizeEvent

func (_htmle *Element) AddResizeEvent(_listener func(*event.UIEvent, *Element))

AddResize is adding doing AddEventListener for 'Resize' on target. This method is returning allocated javascript function that need to be released.

func (*Element) AddWheelEvent

func (_htmle *Element) AddWheelEvent(_listener func(*event.WheelEvent, *Element))

The wheel event fires when the user rotates a wheel button on a pointing device (typically a mouse).

https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event

func (*Element) Attribute

func (elem *Element) Attribute(aname string) (string, bool)

Attribute returns the value of the attribute identified by its name. Returns false if the attribute does not exist.

Blanks at the ends of the name are automatically trimmed. Attribute's name are case sensitive

func (*Element) AttributeIsTrue

func (elem *Element) AttributeIsTrue(aname string) bool

AttributeIsTrue returns true if the attribute exists and if it's value is not false nor 0.

Blanks at the ends of the name are automatically trimmed. Attribute's name are case sensitive.

func (*Element) AttributeString

func (elem *Element) AttributeString() string

AttributeString returns the formated list of attributes, ready to use to generate the tag element.

func (*Element) Blur

func (_htmle *Element) Blur() *Element

Blur removes keyboard focus from the current element.

https://developer.mozilla.org/en-US/docs/Web/API/Element/blur

func (*Element) BoundingClientRect

func (elem *Element) BoundingClientRect() (_rect Rect)

GetBoundingClientRect eturns a DOMRect object providing information about the size of an element and its position relative to the viewport.

https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

func (*Element) ChildFirst

func (elem *Element) ChildFirst() *Element

FirstElementChild returns an element's first child Element, or null if there are no child elements.

https://developer.mozilla.org/en-US/docs/Web/API/Element/firstElementChild

func (*Element) ChildLast

func (elem *Element) ChildLast() *Element

LastElementChild returns an element's last child Element, or null if there are no child elements.

https://developer.mozilla.org/en-US/docs/Web/API/Element/lastElementChild

func (*Element) Children

func (elem *Element) Children() []*Element

Children returns a live HTMLCollection which contains all of the child elements of the element upon which it was called.

Includes only element nodes. To get all child nodes, including non-element nodes like text and comment nodes, use Node.Children

https://developer.mozilla.org/en-US/docs/Web/API/Element/children

func (*Element) ChildrenByClassName

func (elem *Element) ChildrenByClassName(_classNames string) []*Element

GetElementsByClassName returns a live HTMLCollection which contains every descendant element which has the specified class name or names.

https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName

func (*Element) ChildrenByData

func (root *Element) ChildrenByData(_data string, _value string) []*Element

ChildrenMatching make a slice of Element, scaning recursively every children of this Element. Only nodes having data attribites matching _data like "data-myvalue"

func (*Element) ChildrenByTagName

func (elem *Element) ChildrenByTagName(_tagName string) []*Element

GetElementsByTagName returns a live HTMLCollection of elements with the given tag name.

https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName

func (*Element) ChildrenCount

func (elem *Element) ChildrenCount() int

ChildElementCount returns the number of child elements of this element. https://developer.mozilla.org/en-US/docs/Web/API/Element/childElementCount

func (*Element) ChildrenMatching

func (root *Element) ChildrenMatching(_match func(*Element) bool) []*Element

ChildrenMatching make a slice of Element, scaning recursively every children of this Element. Only nodes matching the optional _match function are included.

func (*Element) Classes

func (elem *Element) Classes() string

Classes returns the class object related to elem. If elem is defined, the class object is wrapped with the DOMTokenList collection of the class attribute of elem.

https://developer.mozilla.org/en-US/docs/Web/API/Element/classList

func (*Element) ClientRect

func (elem *Element) ClientRect() (_rect Rect)

ClientRect returns border coordinates of an element in pixels.

Note: This property will round the value to an integer. If you need a fractional value, use element.jsValue.getBoundingClientRect().

func (*Element) Focus

func (_htmle *Element) Focus() *Element

Focus sets focus on the specified element, if it can be focused. The focused element is the element that will receive keyboard and similar events by default.

By default the browser will scroll the element into view after focusing it, and it may also provide visible indication of the focused element (typically by displaying a "focus ring" around the element).

https://developer.mozilla.org/en-US/docs/Web/API/Element/focus

func (*Element) HasClass

func (elem *Element) HasClass(class string) bool

HasClass returns if the class exists in the list of classes.

func (*Element) Id

func (elem *Element) Id() string

Id rrepresents the element's identifier, reflecting the id global attribute. Returns the UNDEFINED_NODE string if elem is nil or not a defined js value. Returns the UNDEFINED_ATTR string if the returned string is empty.

https://developer.mozilla.org/en-US/docs/Web/API/Element/id

func (*Element) InnerHTML

func (elem *Element) InnerHTML() string

AttributeString r InnerHTML gets or sets the HTML or XML markup contained within the element.

To insert the HTML into the document rather than replace the contents of an element, use the method insertAdjacentHTML().

https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML

func (*Element) InnerText

func (_htmle *Element) InnerText() string

InnerText represents the rendered text content of a node and its descendants.

InnerText gets pure text, removing any html or css, while TextContent keeps the representation.

https://developer.mozilla.org/en-US/docs/Web/API/Element/innerText

func (*Element) InsertElement

func (_me *Element) InsertElement(_where INSERT_WHERE, elem *Element)

func (*Element) InsertRawHTML

func (elem *Element) InsertRawHTML(where INSERT_WHERE, unsafeHtml string)

TODO: dom - handle Element.InsertRawHTML exceptions

func (*Element) InsertSnippet

func (elem *Element) InsertSnippet(where INSERT_WHERE, cmp ickcore.Composer) (errx error)

InsertSnippet unfolds and renders the html of the composer and write it into the DOM. The composer and all its embedded components are wrapped with their DOM element and their listeners are added to the DOM. Composer can be either a simple html ElementComposer or an UIComposer.

Returns an error if elem in not in the DOM or the _snippet has an Id and it's already in the DOM. Returns an error if WriteSnippet or mounting process fail.

func (*Element) InsertText

func (_me *Element) InsertText(_where INSERT_WHERE, _format string, _value ...any)

InsertText insert the formated _value as a simple text (not an HTML string) at the _where position. The format string follow the fmt rules: https://pkg.go.dev/fmt#hdr-Printing

func (*Element) IsDefined

func (e *Element) IsDefined() bool

IsDefined returns true if the Element is not nil AND it's type is not TypeNull and not TypeUndefined

func (*Element) IsDisabled

func (elem *Element) IsDisabled() bool

Style returns the style attribute

func (*Element) Name

func (elem *Element) Name() string

Name returns the value of the name attribute. Returns the UNDEFINED_NODE string if elem is nil or not a defined js value. Returns the UNDEFINED_ATTR string if the returned string is empty.

func (*Element) OuterHTML

func (elem *Element) OuterHTML() string

OuterHTML gets the serialized HTML fragment describing the element including its descendants. It can also be set to replace the element with nodes parsed from the given string.

To only obtain the HTML representation of the contents of an element, or to replace the contents of an element, use the innerHTML property instead.

https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML

func (*Element) PickClass

func (elem *Element) PickClass(classlist string, picked string) *Element

PickClass set the picked class and only that one, removing all others in the classlist. If picked is empty or not in the classlist then it's not added.

func (*Element) Remove

func (e *Element) Remove()

Remove removes the element and its listeners from the DOM. Does nothing if e is not defined.

See Web Api Element.Remove.

func (*Element) RemoveAttribute

func (elem *Element) RemoveAttribute(aname string) *Element

RemoveAttribute removes the attribute identified by its name. Does nothing if the name is not in the map.

Blanks at the ends of the name are automatically trimmed. Attribute's name are case sensitive

func (*Element) RemoveClass

func (elem *Element) RemoveClass(lists ...string) *Element

RemoveClass removes each class in lists strings from the class attribute. Each lists class string can be either a single class or a string of multiple classes separated by spaces.

func (*Element) ResetClass

func (elem *Element) ResetClass() *Element

ResetClass removes all classes by removing the class attribute

func (*Element) ScrollIntoView

func (elem *Element) ScrollIntoView() *Element

ScrollIntoView scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.

https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

func (*Element) ScrollRect

func (elem *Element) ScrollRect() (_rect Rect)

ScrollTop gets or sets the number of pixels that an element's content is scrolled vertically.

https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth

func (*Element) SelectorClosest

func (elem *Element) SelectorClosest(_selectors string) *Element

Traverses the element and its parents (heading toward the document root) until it finds a node that matches the specified CSS selector.

https://developer.mozilla.org/en-US/docs/Web/API/Element/closest

func (*Element) SelectorMatches

func (elem *Element) SelectorMatches(_selectors string) bool

Matches tests whether the element would be selected by the specified CSS selector.

https://developer.mozilla.org/en-US/docs/Web/API/Element/matches

func (*Element) SelectorQueryAll

func (elem *Element) SelectorQueryAll(_selectors string) []*Element

QuerySelectorAll returns a static (not live) NodeList representing a list of elements matching the specified group of selectors which are descendants of the element on which the method was called.

https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll

func (*Element) SelectorQueryFirst

func (elem *Element) SelectorQueryFirst(_selectors string) *Element

QuerySelector returns the first element that is a descendant of the element on which it is invoked that matches the specified group of selectors.

https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector

func (*Element) SetAccessKey

func (_htmle *Element) SetAccessKey(key string) *Element

AccessKey A string indicating the single-character keyboard key to give access to the button.

func (*Element) SetAttribute

func (elem *Element) SetAttribute(key string, value string) *Element

SetAttribute creates an attribute in the map and set its value. If the attribute already exists in the map it is updated.

Blanks at the ends of the name are automatically trimmed. Attribute's name are case sensitive

func (*Element) SetAttributeIf

func (elem *Element) SetAttributeIf(condition bool, aname string, valueiftrue string, valueiffalse ...string) *Element

SetAttributeIf SetAttribute if the condition is true, otherwise remove the attribute.

Blanks at the ends of the name are automatically trimmed. Attribute's name are case sensitive.

func (*Element) SetBool

func (elem *Element) SetBool(aname string, f bool) *Element

SetBoolAttribute sets or overwrites a boolean attribute and returns the map to allow chainning.

Blanks at the ends of the name are automatically trimmed. Attribute's name is case sensitive.

func (*Element) SetClassIf

func (elem *Element) SetClassIf(condition bool, classiftrue string, classiffalse ...string) *Element

SetClassIf adds each c classe to the class attribute if the condition is true, otherwise remove them.

func (*Element) SetDisabled

func (elem *Element) SetDisabled(f bool) *Element

SetDisabled sets the boolean disabled attribute

func (*Element) SetId

func (elem *Element) SetId(id string) *Element

Id represents the element's identifier, reflecting the id global attribute.

https://developer.mozilla.org/en-US/docs/Web/API/Element/id

func (*Element) SetName

func (elem *Element) SetName(name string) *Element

SetName sets or overwrites the name attribute. In HTML5 name is case sensitive. blanks at the ends of the id are automatically trimmed. if name is empty, the name attribute is removed.

func (*Element) SetStyle

func (elem *Element) SetStyle(style string) *Element

SetStyle sets or overwrites the style attribute.

func (*Element) SetTabIndex

func (elem *Element) SetTabIndex(index int) *Element

TabIndex represents the tab order of the current element.

Tab order is as follows:

  1. Elements with a positive tabindex. Elements that have identical tabindex values should be navigated in the order they appear. Navigation proceeds from the lowest tabindex to the highest tabindex.
  2. Elements that do not support the tabindex attribute or support it and assign tabindex to 0, in the order they appear.
  3. Elements that are disabled do not participate in the tabbing order.

Values don't need to be sequential, nor must they begin with any particular value. They may even be negative, though each browser trims very large values.

https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/tabindex

func (*Element) SiblingNext

func (elem *Element) SiblingNext() *Element

NextElementSibling returns the element immediately following the specified one in its parent's children list, or null if the specified element is the last one in the list.

https://developer.mozilla.org/en-US/docs/Web/API/Element/nextElementSibling

func (*Element) SiblingPrevious

func (elem *Element) SiblingPrevious() *Element

PreviousElementSibling returns the Element immediately prior to the specified one in its parent's children list, or null if the specified element is the first one in the list.

https://developer.mozilla.org/en-US/docs/Web/API/Element/previousElementSibling

func (*Element) Style

func (elem *Element) Style() (style string)

Style returns the style attribute

func (*Element) SwitchClasses

func (elem *Element) SwitchClasses(remove string, new string) *Element

SwitchClass removes one class and set a new one

func (*Element) TabIndex

func (elem *Element) TabIndex() (idx int)

TabIndex represents the tab order of the current element.

Tab order is as follows:

  1. Elements with a positive tabindex. Elements that have identical tabindex values should be navigated in the order they appear. Navigation proceeds from the lowest tabindex to the highest tabindex.
  2. Elements that do not support the tabindex attribute or support it and assign tabindex to 0, in the order they appear.
  3. Elements that are disabled do not participate in the tabbing order.

Values don't need to be sequential, nor must they begin with any particular value. They may even be negative, though each browser trims very large values.

https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/tabindex

func (*Element) TagName

func (elem *Element) TagName() string

TagName returns the tag name of the element on which it's called. Always in Uppercase for HTML element.

https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName

func (*Element) ToggleAttribute

func (elem *Element) ToggleAttribute(aname string) *Element

ToggleAttribute toggles an attribute like a boolean. If the attribute exists it's removed, if it does not exists it's created without value.

Blanks at the ends of the name are automatically trimmed. Attribute's name are case sensitive

type INSERT_WHERE

type INSERT_WHERE int
const (
	INSERT_BEFORE_ME   INSERT_WHERE = iota // Before the Element itself.
	INSERT_FIRST_CHILD                     // Just inside the element, before its first child.
	INSERT_LAST_CHILD                      // Just inside the element, after its last child.
	INSERT_AFTER_ME                        // After the element itself.
	INSERT_OUTER                           // like outerhtml
	INSERT_BODY                            // like inner html
)

type NODE_POSITION

type NODE_POSITION int

An integer value representing otherNode's position relative to node as a bitmask.

const (
	NODEPOS_UNDEF                   NODE_POSITION = 0x00
	NODEPOS_DISCONNECTED            NODE_POSITION = 0x01
	NODEPOS_PRECEDING               NODE_POSITION = 0x02
	NODEPOS_FOLLOWING               NODE_POSITION = 0x04
	NODEPOS_CONTAINS                NODE_POSITION = 0x08
	NODEPOS_CONTAINED_BY            NODE_POSITION = 0x10
	NODEPOS_IMPLEMENTATION_SPECIFIC NODE_POSITION = 0x20
)

type NODE_TYPE

type NODE_TYPE int
const (
	NT_ALL                    NODE_TYPE = 0xFFFF
	NT_UNDEF                  NODE_TYPE = 0x0000
	NT_ELEMENT                NODE_TYPE = 0x0001 // An Element node like <p> or <div>. aka ELEMNT_NODE.
	NT_ATTRIBUTE              NODE_TYPE = 0x0002 // An Attribute of an Element. aka ATTRIBUTE_NODE.
	NT_TEXT                   NODE_TYPE = 0x0003 // The actual Text inside an Element or Attr. aka TEXT_NODE.
	NT_CDATA_SECTION          NODE_TYPE = 0x0004 // A CDATASection, such as <!CDATA[[ … ]]>. aka CDATA_SECTION_NODE.
	NT_PROCESSING_INSTRUCTION NODE_TYPE = 0x0007 // A ProcessingInstruction of an XML document, such as <?xml-stylesheet … ?>.
	NT_COMMENT                NODE_TYPE = 0x0008 // A Comment node, such as <!-- … -->. aka COMMENT_NODE.
	NT_DOCUMENT               NODE_TYPE = 0x0009 // A Document node. aka DOCUMENT_NODE.
	NT_DOCUMENT_TYPE          NODE_TYPE = 0x000A // A DocumentType node, such as <!DOCTYPE html>. aka DOCUMENT_TYPE_NODE.
	NT_DOCUMENT_FRAGMENT      NODE_TYPE = 0x000B // A DocumentFragment node. aka DOCUMENT_FRAGMENT_NODE.

	NT_ENTITY_REFERENCE NODE_TYPE = 0x0005 // Deprecated
	NT_ENTITY           NODE_TYPE = 0x0006 // Deprecated
	NT_NOTATION         NODE_TYPE = 0x000C // Deprecated
)

func (NODE_TYPE) String

func (nt NODE_TYPE) String() string

type Node

type Node struct {
	js.JSValue // embedded js.JSValue
	// contains filtered or unexported fields
}

https://developer.mozilla.org/en-US/docs/Web/API/Node

func CastNode

func CastNode(_jsvp js.JSValueProvider) *Node

CastNode is casting a js.Value into Node.

func CastNodes

func CastNodes(_jsvp js.JSValueProvider) []*Node

func CreateTextNode

func CreateTextNode(_text string) *Node

CreateTextNode creates a text node

func (*Node) AppendChild

func (_parentnode *Node) AppendChild(newnode *Node) *Node

AppenChild adds a node to the end of the list of children of a specified parent node. If the given child is a reference to an existing node in the document, appendChild() moves it from its current position to the new position.

Returns the _parent to enable chaining calls.

https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild

func (*Node) BaseURI

func (_node *Node) BaseURI() *url.URL

BaseURI returns the absolute base URL of the document containing the node.

https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI

func (*Node) ChildFirst

func (_node *Node) ChildFirst() *Node

FirstChild returns the node's first child in the tree, or null if the node has no children.

https://developer.mozilla.org/en-US/docs/Web/API/Node/firstChild

func (*Node) ChildLast

func (_node *Node) ChildLast() *Node

LastChild returns the last child of the node. If its parent is an element, then the child is generally an element node, a text node, or a comment node. It returns null if there are no child nodes.

https://developer.mozilla.org/en-US/docs/Web/API/Node/lastChild

func (*Node) Children

func (_node *Node) Children() []*Node

ChildNodes returns a ~live~ static NodeList of child nodes of the given element where the first child node is assigned index 0. Child nodes include elements, text and comments.

https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes

func (*Node) ChildrenMatching

func (_root *Node) ChildrenMatching(_filter NODE_TYPE, _match func(*Node) bool) []*Node

ChildrenMatching make a slice of nodes, scaning recursively every children of this Node. Only nodes matching _filter AND the optional _match function are included.

func (*Node) ComparePosition

func (_onenode *Node) ComparePosition(_other *Node) NODE_POSITION

CompareDocumentPosition reports the position of its argument node relative to the node on which it is called.

https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition

func (*Node) HasChildren

func (_node *Node) HasChildren() bool

HasChildNodes returns a boolean value indicating whether the given Node has child nodes or not.

https://developer.mozilla.org/en-US/docs/Web/API/Node/hasChildNodes

func (*Node) InsertBefore

func (_parentnode *Node) InsertBefore(newnode *Node, refnode *Node) *Node

InsertBefore inserts a newnode before a refnode. if refnode is nil, then newNode is inserted at the end of node's child nodes.

If the given node already exists in the document, insertBefore() moves it from its current position to the new position. (That is, it will automatically be removed from its existing parent before appending it to the specified new parent.)

Returns the _parent to enable chaining calls.

https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore

func (*Node) IsDefined

func (_node *Node) IsDefined() bool

IsDefined returns true if the Element is not nil AND it's type is not TypeNull and not TypeUndefined

func (Node) IsInDOM

func (n Node) IsInDOM() bool

IsInDOM returns a boolean indicating whether the node is within a Document object. Returns false if the node is not defined.

https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected

func (*Node) IsSameNode

func (_node *Node) IsSameNode(_otherNode *Node) bool

IsSameNode tests whether two nodes are the same (in other words, whether they reference the same object). https://developer.mozilla.org/en-US/docs/Web/API/Node/isSameNode

func (*Node) NodeName

func (_node *Node) NodeName() string

Values for the different types of nodes are:

  • Attr: the qualified name of the attribute.
  • CDATASection: "#cdata-section".
  • Comment: "#comment".
  • Document: "#document".
  • DocumentFragment: "#document-fragment".
  • DocumentType: the value of DocumentType.name
  • Element: the uppercase name of the element tag if an HTML element, or the lowercase element tag if an XML element (like a SVG or MATHML element).
  • ProcessingInstruction: The value of ProcessingInstruction.target
  • Text: "#text".

NodeName returns the name of the current node as a string.

func (*Node) NodeType

func (_node *Node) NodeType() NODE_TYPE

NodeType It distinguishes different kind of nodes from each other, such as elements, text and comments.

https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType

func (*Node) NodeValue

func (_node *Node) NodeValue() string

NodeValue is a string containing the value of the current node, if any.

For the document itself, nodeValue returns null. For text, comment, and CDATA nodes, nodeValue returns the content of the node. For attribute nodes, the value of the attribute is returned.

https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue

func (Node) ParentElement

func (_node Node) ParentElement() *Element

ParentElement returns the DOM node's parent Element, or null if the node either has no parent, or its parent isn't a DOM Element. https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement

func (Node) ParentNode

func (_node Node) ParentNode() *Node

ParentNode returns the parent of the specified node in the DOM tree.

https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode

func (*Node) RemoveChild

func (_parentnode *Node) RemoveChild(_child *Node) *Node

RemoveChild removes a child node from the DOM

Returns the _parent to enable chaining calls.

https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild

func (*Node) RemoveListeners

func (n *Node) RemoveListeners()

RemoveListeners removes all event listeners and release ressources allocated fot the associated js func To be called only when event handlers have been added to the node.

func (*Node) ReplaceChild

func (_parentnode *Node) ReplaceChild(_newchild *Node, _oldchild *Node) *Node

ReplaceChild replaces a child node within the given (parent) node.

Returns the _parent to enable chaining calls.

https://developer.mozilla.org/en-US/docs/Web/API/Node/replaceChild

func (Node) RootNode

func (_node Node) RootNode() *Node

GetRootNode returns the context object's root, which optionally includes the shadow root if it is available.

https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode

func (*Node) SetNodeValue

func (_node *Node) SetNodeValue(value string) *Node

NodeValue is a string containing the value of the current node, if any.

For the document itself, nodeValue returns null. For text, comment, and CDATA nodes, nodeValue returns the content of the node. For attribute nodes, the value of the attribute is returned.

https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue

func (*Node) SetTextContent

func (_node *Node) SetTextContent(value string) *Node

TextContent represents the text content of the node and its descendants.

https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent

func (*Node) SiblingNext

func (_node *Node) SiblingNext() *Node

NextSibling returns the node immediately following the specified one in their parent's childNodes, or returns null if the specified node is the last child in the parent element.

https://developer.mozilla.org/en-US/docs/Web/API/Node/nextSibling

func (*Node) SiblingPrevious

func (_node *Node) SiblingPrevious() *Node

PreviousSibling returns the node immediately preceding the specified one in its parent's childNodes list, or null if the specified node is the first in that list.

https://developer.mozilla.org/en-US/docs/Web/API/Node/previousSibling

func (*Node) TextContent

func (_node *Node) TextContent() string

TextContent represents the text content of the node and its descendants.

https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent

type Rect

type Rect struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
}

type UI

type UI struct {
	DOM Element
}

UISnippet combines an htmlSnippet allowing html rendering of ick-name tags in different ways, and a wrapped dom.Element allowing event listening and other direct DOM interactions.

func (*UI) AddListeners

func (ui *UI) AddListeners()

AddListeners does nothing by default. Can be implemented by the component embedding UISnippet.

func (*UI) RefreshContent

func (ui *UI) RefreshContent(cmp ickcore.ContentComposer) (errx error)

RefreshContent renders the cmp's content and re-insert it into the DOM. RefreshContent removes and re-add all listeners

func (*UI) RemoveListeners

func (ui *UI) RemoveListeners()

RemoveListeners remove all event handlers attached to this UISnippet Element. If RemoveListeners is implemented by the component embedding UISnippet then the UISnippet one should be called. Usually RemoveListeners does not need to be overloaded because every listeners added to the Element are automatically removed.

func (*UI) Wrap

func (ui *UI) Wrap(jsvp js.JSValueProvider)

Wrap implements the JSValueWrapper to enable wrapping of a dom.Element usually to wrap embedded component instantiated during unfolding an html string. Does not need to be overloaded by the component embedding UISnippet.

type UIComposer

type UIComposer interface {
	ickcore.TagBuilder
	ickcore.ContentComposer

	Wrap(js.JSValueProvider)

	AddListeners()

	RemoveListeners()
}

Jump to

Keyboard shortcuts

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