class dom::Elem

sys::Obj
  dom::Elem

@Js

Source

Elem models a DOM element object.

See pod doc for details.

add

@Operator
virtual This add(Elem child)

Source

Add a new element as a child to this element. Return this.

addAll

This addAll(Elem[] elems)

Source

Add all elements to this element. Returns this.

animateStart

Void animateStart(KeyFrames frames, [Str:Obj]? opts, Duration dur)

Source

Start an animation on this element using the given key frames.

frames := KeyFrames([
  KeyFrame("0%",   ["transform": "scale(1)"]),
  KeyFrame("50%",  ["transform": "scale(1.1)"]),
  KeyFrame("100%", ["transform": "scale(1)"]),
])

animate(frames, null, 5sec)
animate(frames, ["animation-iteration-count":"infinite"], 1sec)
animateStop

Void animateStop()

Source

Stop the current animation on this element, or do nothing if no animation in progress.

blur

virtual Void blur()

Source

Remove focus from this elem.

children

Elem[] children()

Source

Get the child nodes of this element.

containsChild

Bool containsChild(Elem elem)

Source

Return true if given element is a descendant of this node, or false if not.

draggable

Bool draggable

Source

The draggable attribute for this element.

enabled

virtual Bool? enabled

Source

The enabled attribute for this element, or null if one not applicable. This is typically only valid for form elements.

firstChild

Elem? firstChild()

Source

Get the first child node of this element, or null if this element has no children.

focus

virtual Void focus()

Source

Request keyboard focus on this elem.

get

@Operator
Obj? get(Str name, Obj? def := null)

Source

Get an attribute by name. If not found return the specificed default value.

hasFocus

virtual Bool hasFocus()

Source

Return true if this elem has focus.

html

Str html

Source

The HTML markup contained in this element.

id

Str id

Source

The id for this element.

insertBefore

virtual This insertBefore(Elem child, Elem ref)

Source

Insert a new element as a child to this element before the specified reference element. The reference element must be a child of this element. Returns this.

lastChild

Elem? lastChild()

Source

Get the last child node of this element, or null if this element has no children.

make

new make(Str tagName := "div")

Source

Create a new Elem in the current Doc.

nextSibling

Elem? nextSibling()

Source

Get the next sibling to this element, or null if this is the last element under its parent.

onEvent

Func onEvent(Str type, Bool useCapture, |Event| handler)

Source

Attach an event handler for the given event on this element. Returns callback function instance.

pagePos

Pos pagePos()

Source

Position of element relative to the whole document.

parent

Elem? parent()

Source

Get the parent Elem of this element, or null if this element has no parent.

pos

Pos pos

Source

Position of element relative to its parent in pixels.

prevSibling

Elem? prevSibling()

Source

Get the previous sibling to this element, or null if this is the first element under its parent.

querySelector

Elem? querySelector(Str selectors)

Source

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

querySelectorAll

Elem[] querySelectorAll(Str selectors)

Source

Returns a list of all elements descended from this element on which it is invoked that match the specified group of CSS selectors.

remove

virtual This remove(Elem child)

Source

Remove a child element from this element. Return this.

removeAll

This removeAll()

Source

Remove all children from this element. Returns this.

removeEvent

Void removeEvent(Str type, Bool useCapture, Func handler)

Source

Remove the given event handler from this element. If this handler was not registered, this method does nothing.

replace

virtual This replace(Elem oldChild, Elem newChild)

Source

Replace existing child node with a new child. Returns this.

scrollPos

Pos scrollPos

Source

Top left scroll position of element.

scrollSize

Size scrollSize()

Source

Scrollable size of element.

set

@Operator
Void set(Str name, Obj? val)

Source

Set an attribute to the given value.

size

Size size

Source

Size of element in pixels.

style

Style style()

Source

Get the Style instance for this element.

tagName

Str tagName()

Source

Get the tag name for this element.

text

Str text

Source

Text content contained in this element.

transition

Void transition(Str:Obj props, [Str:Obj]? opts, Duration dur, |Elem|? onComplete := null)

Source

Transition a set of CSS properties.

transition(["opacity": "0.5"], null, 1sec) { echo("done!") }
transition(["opacity": "0.5"], ["transition-delay": 500ms], 1sec) { echo("done!") }
trap

virtual override Obj? trap(Str name, Obj?[]? args := null)

Source

Get or set an attribute.