A sealed algebraic data type (ADT) representing an HTML document node.
The Dom trait models HTML as an abstract syntax tree where each node is either:
- Text content (automatically HTML-escaped during rendering)
- An empty node (renders to nothing)
- An Element with a tag, attributes, and child nodes
===Rendering=== Text content is HTML-escaped by default to prevent injection attacks. However, Script and Style elements intentionally render their children WITHOUT escaping, allowing inline JavaScript and CSS to be rendered as-is.
Use render for minified HTML or render(indent: Int) for pretty-printed output with N spaces per indentation level.
===Tree Operations=== The ADT supports traversal via collect, filter, find, and transform methods for navigating and transforming the tree structure.
Attributes
- See also
- Companion
- object
- Source
- Dom.scala
- Graph
-
- Supertypes
- Known subtypes
-
class Doctypetrait Voidclass VoidGenerictrait Elementtrait Celltrait Tdclass TdElementtrait Thclass ThElementclass Generictrait Liclass LiElementclass OptElementclass OptgroupElementclass Scripttrait SelectChildtrait Opttrait Optgroupclass Styletrait Trclass TrElementobject Emptyclass TextShow all
Members list
Value members
Concrete methods
Collects all nodes in the tree matching the given partial function.
Collects all nodes in the tree matching the given partial function.
Traverses the entire tree in depth-first order, applying the partial function to each node and collecting matches.
Value parameters
- pf
-
the partial function to apply; nodes that match contribute their transformed values
Attributes
- Returns
-
a list of matching nodes (or their transformed versions)
- Source
- Dom.scala
Filters the tree to keep only nodes satisfying the predicate.
Filters the tree to keep only nodes satisfying the predicate.
Removes any node for which the predicate returns false, and recursively filters children. Empty branches collapse to Empty.
Value parameters
- predicate
-
the condition each node must satisfy
Attributes
- Returns
-
a new tree with non-matching nodes removed
- Source
- Dom.scala
Finds the first node in the tree satisfying the predicate.
Finds the first node in the tree satisfying the predicate.
Traverses the tree in depth-first order and returns the first matching node.
Value parameters
- predicate
-
the condition to search for
Attributes
- Returns
-
Some(node)if a match is found,Noneotherwise - Source
- Dom.scala
Checks whether this node renders to empty HTML.
Checks whether this node renders to empty HTML.
Returns true if the node is Empty or a Text with empty content.
Attributes
- Returns
-
true if this node produces no output when rendered
- Source
- Dom.scala
Renders the DOM tree to a minified HTML string.
Renders the DOM tree to a minified HTML string.
Text content is HTML-escaped. Script and Style elements render their children without escaping to allow inline code.
Attributes
- Returns
-
minified HTML output with no extra whitespace
- Source
- Dom.scala
Renders the DOM tree to a pretty-printed HTML string with indentation.
Renders the DOM tree to a pretty-printed HTML string with indentation.
Text content is HTML-escaped. Script and Style elements render their children without escaping to allow inline code.
Value parameters
- indent
-
the number of spaces per indentation level; if <= 0, behaves like
render
Attributes
- Returns
-
formatted HTML with newlines and indentation
- Source
- Dom.scala
Renders the DOM tree to a minified HTML string (alias for render).
Renders the DOM tree to a minified HTML string (alias for render).
Attributes
- Returns
-
minified HTML output
- Source
- Dom.scala
Selects all descendant nodes matching the given CSS selector.
Selects all descendant nodes matching the given CSS selector.
Value parameters
- selector
-
the CSS selector to match against
Attributes
- Returns
-
a DomSelection containing all matching descendant nodes
- Source
- Dom.scala
Transforms every node in the tree using the given function.
Transforms every node in the tree using the given function.
Applies the transformation function to each node in depth-first order, then recursively transforms children of Elements. Suitable for rewriting the tree, e.g., removing nodes, modifying attributes, or simplifying structure.
Value parameters
- f
-
the transformation function to apply to each node
Attributes
- Returns
-
a new tree with all nodes transformed
- Source
- Dom.scala
Inherited methods
The name of the n^th^ element of this product, 0-based. In the default implementation, an empty string.
The name of the n^th^ element of this product, 0-based. In the default implementation, an empty string.
Value parameters
- n
-
the index of the element name to return
Attributes
- Returns
-
the name of the specified element
- Throws
-
IndexOutOfBoundsException
if the
nis out of range(n < 0 || n >= productArity). - Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
A string used in the toString methods of derived classes. Implementations may override this method to prepend a string prefix to the result of toString methods.
A string used in the toString methods of derived classes. Implementations may override this method to prepend a string prefix to the result of toString methods.
Attributes
- Returns
-
in the default implementation, the empty string
- Inherited from:
- Product
- Source
- Product.scala
Inherited and Abstract methods
Checks whether this instance can possibly equal that.
Checks whether this instance can possibly equal that.
A method that should be called from every well-designed equals method that is open to be overridden in a subclass. See Programming in Scala, Chapter 28 for discussion and design.
Value parameters
- that
-
the value being probed for possible equality
Attributes
- Returns
-
true if this instance can possibly equal
that, otherwise false - Inherited from:
- Equals
- Source
- Equals.scala
The size of this product.
The size of this product.
Attributes
- Returns
-
for a product
A(x,,1,,, ..., x,,k,,), returnsk - Inherited from:
- Product
- Source
- Product.scala
The n^th^ element of this product, 0-based. In other words, for a product A(x,,1,,, ..., x,,k,,), returns x,,(n+1),, where `0 = productArity).
The n^th^ element of this product, 0-based. In other words, for a product A(x,,1,,, ..., x,,k,,), returns x,,(n+1),, where `0 = productArity).
Attributes
- Returns
-
the element
nelements after the first element - Inherited from:
- Product
- Source
- Product.scala