DomSelection

zio.blocks.html.DomSelection
See theDomSelection companion object
final case class DomSelection(nodes: Chunk[Dom]) extends AnyVal

A wrapper around Chunk[Dom] that provides fluent chaining for CSS selector-based DOM navigation and querying operations.

DomSelection enables a fluent API style for navigating through DOM structures:

 dom.select(CssSelector.Element("div")).children.select(CssSelector.Element("p")).texts

The selection can contain zero, one, or multiple DOM nodes, supporting both single-value navigation and multi-value queries.

Attributes

Companion
object
Source
DomSelection.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class AnyVal
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Combines two selections.

Combines two selections.

Attributes

Source
DomSelection.scala
def apply(index: Int): DomSelection

Returns a selection containing the node at the given index.

Returns a selection containing the node at the given index.

Attributes

Source
DomSelection.scala
def attrs(name: String): Chunk[String]

Extracts attribute values with the given name from all element nodes in this selection.

Extracts attribute values with the given name from all element nodes in this selection.

Attributes

Source
DomSelection.scala

Returns the direct children of all element nodes in this selection.

Returns the direct children of all element nodes in this selection.

Attributes

Source
DomSelection.scala

Returns all descendant nodes of all element nodes in this selection (excluding the nodes themselves).

Returns all descendant nodes of all element nodes in this selection (excluding the nodes themselves).

Attributes

Source
DomSelection.scala

Filters this selection to keep only Element nodes.

Filters this selection to keep only Element nodes.

Attributes

Source
DomSelection.scala
def filter(predicate: Dom => Boolean): DomSelection

Filters the selection by a predicate.

Filters the selection by a predicate.

Attributes

Source
DomSelection.scala

Returns a selection containing only the first node.

Returns a selection containing only the first node.

Attributes

Source
DomSelection.scala
def headOption: Option[Dom]

Returns the first node if present.

Returns the first node if present.

Attributes

Source
DomSelection.scala
def isEmpty: Boolean

Returns true if this selection contains no nodes.

Returns true if this selection contains no nodes.

Attributes

Source
DomSelection.scala

Returns a selection containing only the last node.

Returns a selection containing only the last node.

Attributes

Source
DomSelection.scala
def length: Int

Returns the number of selected nodes.

Returns the number of selected nodes.

Attributes

Source
DomSelection.scala

Applies a transformation function to all Element nodes in this selection, returning the modified nodes.

Applies a transformation function to all Element nodes in this selection, returning the modified nodes.

Attributes

Source
DomSelection.scala
def nonEmpty: Boolean

Returns true if this selection contains at least one node.

Returns true if this selection contains at least one node.

Attributes

Source
DomSelection.scala

Returns an empty selection (all nodes removed).

Returns an empty selection (all nodes removed).

Attributes

Source
DomSelection.scala
def replaceAll(replacement: Dom): DomSelection

Replaces all nodes in this selection with the given replacement.

Replaces all nodes in this selection with the given replacement.

Attributes

Source
DomSelection.scala
def select(selector: CssSelector): DomSelection

Selects all descendant nodes matching the given CSS selector.

Selects all descendant nodes matching the given CSS selector.

For simple selectors (Element, Class, Id, Universal, And, Or, Not, Attribute), searches all descendants of each node in this selection. For structural selectors (Child, Descendant), walks the tree accordingly.

Value parameters

selector

the CSS selector to match against

Attributes

Returns

a new selection containing all matching nodes

Source
DomSelection.scala
def texts: Chunk[String]

Extracts text content from all nodes in this selection.

Extracts text content from all nodes in this selection.

For Text nodes, returns the content directly. For Element nodes, returns the concatenated text of all child Text nodes.

Attributes

Source
DomSelection.scala
def toChunk: Chunk[Dom]

Returns the selected nodes as a Chunk.

Returns the selected nodes as a Chunk.

Attributes

Source
DomSelection.scala
def withAttribute(name: String): DomSelection

Keeps only elements that have the given attribute (any value).

Keeps only elements that have the given attribute (any value).

Attributes

Source
DomSelection.scala
def withAttribute(name: String, value: String): DomSelection

Keeps only elements that have the given attribute with the given value.

Keeps only elements that have the given attribute with the given value.

Attributes

Source
DomSelection.scala
def withClass(cls: String): DomSelection

Keeps only elements that have the given CSS class.

Keeps only elements that have the given CSS class.

Attributes

Source
DomSelection.scala
def withId(idValue: String): DomSelection

Keeps only elements that have the given id.

Keeps only elements that have the given id.

Attributes

Source
DomSelection.scala
def withTag(tag: String): DomSelection

Keeps only elements with the given tag name.

Keeps only elements with the given tag name.

Attributes

Source
DomSelection.scala

Inherited methods

def productElementNames: Iterator[String]

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
def productIterator: Iterator[Any]

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