DomApi

object DomApi
class Object
trait Matchable
class Any
DomApi.type

Value members

Concrete methods

def addEventListener[Ev <: Event](element: Base, listener: EventListener[Ev, _]): Unit

Events

Events

def appendChild(parent: Base, child: Base): Boolean

Tree functions

Tree functions

def assertHtmlElement(node: Node, clue: String): Element
def assertSingleNode(nodes: Array[Node], clue: String): Node
def assertSvgElement(node: Node, clue: String): Element
def assertTagMatches[Ref <: Element](tag: Tag[ReactiveElement[Ref]], node: Node, clue: String): Ref
def createCommentNode(text: String): Comment

Comment Nodes

Comment Nodes

def createHtmlElement[Ref <: Element](tag: HtmlTag[Ref]): Ref

HTML Elements

HTML Elements

def createSvgElement[Ref <: Element](tag: SvgTag[Ref]): Ref

SVG Elements

SVG Elements

def createTextNode(text: String): Text

Text Nodes

Text Nodes

def debugNodeDescription(node: Node): String
Returns:

e.g. a, div#mainSection, span.sideNote.sizeSmall

def debugNodeInnerHtml(node: Node): String
def debugNodeOuterHtml(node: Node): String
def debugPath(element: Node, initial: List[String]): List[String]
Returns:

hierarchical path describing the position and identity of this node, starting with the root.

def getAriaAttribute[V](element: Base, attr: AriaAttr[V]): UndefOr[V]

Aria attributes

Aria attributes

def getAriaAttributeRaw(element: Base, attr: AriaAttr[_]): UndefOr[String]
def getChecked(element: Element): UndefOr[Boolean]

Input related stuff

Input related stuff

def getHtmlAttribute[V](element: Base, attr: HtmlAttr[V]): UndefOr[V]

HTML Attributes

HTML Attributes

def getHtmlAttributeRaw(element: Base, attr: HtmlAttr[_]): UndefOr[String]
def getHtmlProperty[V, DomV](element: Base, prop: HtmlProp[V, DomV]): UndefOr[V]

Returns js.undefined when the property is missing on the element. If the element type supports this property, it should never be js.undefined.

Returns js.undefined when the property is missing on the element. If the element type supports this property, it should never be js.undefined.

def getHtmlPropertyRaw[V, DomV](element: Base, prop: HtmlProp[V, DomV]): UndefOr[DomV]
def getHtmlStyleRaw(element: Base, styleProp: StyleProp[_]): String

Note: this only gets inline style values – those set via the style attribute, which includes all style props set by Laminar. It does not account for CSS declarations in <style> tags.

Note: this only gets inline style values – those set via the style attribute, which includes all style props set by Laminar. It does not account for CSS declarations in <style> tags.

Returns empty string if the given style property is not defined in this element's inline styles.

See https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/getPropertyValue Contrast with https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle

def getSvgAttribute[V](element: Base, attr: SvgAttr[V]): UndefOr[V]

SVG Attributes

SVG Attributes

def getSvgAttributeRaw(element: Base, attr: SvgAttr[_]): UndefOr[String]
def getValue(element: Element): UndefOr[String]
def insertBefore(parent: Base, newChild: Base, referenceChild: Base): Boolean
def isCustomElement(element: Element): Boolean

Custom Elements

Custom Elements

def removeAriaAttribute(element: Base, attr: AriaAttr[_]): Unit
def removeChild(parent: Base, child: Base): Boolean
def removeEventListener[Ev <: Event](element: Base, listener: EventListener[Ev, _]): Unit
def removeHtmlAttribute(element: Base, attr: HtmlAttr[_]): Unit
def removeSvgAttribute(element: Base, attr: SvgAttr[_]): Unit
def replaceChild(parent: Base, newChild: Base, oldChild: Base): Boolean
def setAriaAttribute[V](element: Base, attr: AriaAttr[V], value: V): Unit
def setChecked(element: Element, checked: Boolean): Boolean
Returns:

whether the operation succeeded

def setCommentNodeText(node: CommentNode, text: String): Unit
def setHtmlAnyStyle[V](element: Base, style: StyleProp[V], value: V | String): Unit
def setHtmlAttribute[V](element: Base, attr: HtmlAttr[V], value: V): Unit
def setHtmlProperty[V, DomV](element: Base, prop: HtmlProp[V, DomV], value: V): Unit
def setHtmlStringStyle(element: Base, styleProp: StyleProp[_], value: String): Unit
def setHtmlStyle[V](element: Base, styleProp: StyleProp[V], value: V): Unit
def setSvgAttribute[V](element: Base, attr: SvgAttr[V], value: V): Unit
def setTextNodeText(node: TextNode, text: String): Unit
def setValue(element: Element, value: String): Boolean
Returns:

whether the operation succeeded

def unsafeParseHtmlString(dangerousHtmlString: String): Element

#WARNING: Only use on trusted HTML strings. HTML strings can contain embedded Javascript code, which this function will execute blindly!

#WARNING: Only use on trusted HTML strings. HTML strings can contain embedded Javascript code, which this function will execute blindly!

Note: this expects the html string to contain one HTML element, and will throw otherwise (e.g. if given a text node, an SVG, or multiple elements)

def unsafeParseHtmlString[Ref <: Element](tag: HtmlTag[Ref], dangerousHtmlString: String): Ref

#WARNING: Only use on trusted HTML strings. HTML strings can contain embedded Javascript code, which this function will execute blindly!

#WARNING: Only use on trusted HTML strings. HTML strings can contain embedded Javascript code, which this function will execute blindly!

Note: this expects the html string to contain one element matching the tag name, and will throw otherwise (e.g. if given a text node, an element with a different tag name, or multiple elements)

def unsafeParseHtmlStringIntoNodeArray(dangerousHtmlString: String): Array[Node]

#WARNING: Only use on trusted HTML strings. HTML strings can contain embedded Javascript code, which this function will execute blindly!

#WARNING: Only use on trusted HTML strings. HTML strings can contain embedded Javascript code, which this function will execute blindly!

Note: This method does not work in Internet Explorer. See https://stackoverflow.com/q/10585029 for the issues with various approaches. Use this if you need IE support: https://gist.github.com/Munawwar/6e6362dbdf77c7865a99

def unsafeParseSvgString(dangerousSvgString: String): Element

#WARNING: Only use on trusted SVG strings. SVG strings can contain embedded Javascript code, which this function will execute blindly!

#WARNING: Only use on trusted SVG strings. SVG strings can contain embedded Javascript code, which this function will execute blindly!

Note: this expects the svg string to contain one HTML element, and will throw otherwise (e.g. if given a text node, HTML, or multiple elements)

def unsafeParseSvgString[Ref <: Element](tag: SvgTag[Ref], dangerousSvgString: String): Ref

#WARNING: Only use on trusted SVG strings. SVG strings can contain embedded Javascript code, which this function will execute blindly!

#WARNING: Only use on trusted SVG strings. SVG strings can contain embedded Javascript code, which this function will execute blindly!

Note: this expects the svg string to contain one element matching the tag name, and will throw otherwise (e.g. if given a text node, an element with a different tag name, or multiple elements)

def unsafeParseSvgStringIntoNodeArray(dangerousSvgString: String): Array[Node]

#WARNING: Only use on trusted SVG strings. SVG strings can contain embedded Javascript code, which this function will execute blindly!

#WARNING: Only use on trusted SVG strings. SVG strings can contain embedded Javascript code, which this function will execute blindly!