View Source Tamnoon.DOM.Node (Tamnoon v1.0.0-rc.3)

Represents a DOM node. Accepts two parameters for how to select the node, :selector_type and :selector_value. For example, when :selector_type is :id and :selector_value is "id-to-select", it will be equivalent to using document.getElementById("id-to-select") in JS.

:selector_type can be set as :iteration_placeholder, which is a special value intended for use with Tamnoon.DOM.Actions.ForEach, and will represent the argument that will be each node of the collection.

Fields

  • :selector_type – an atom indicating the type of selector.

    • Expected values: :id, :xpath, :from_string, :first_element, :last_element, :iteration_placeholder.
  • :selector_value – the value associated with the selector.

Summary

Functions

Constructs a Tamnoon.DOM.Node.t/0 with the following arguments

Types

@type t() :: %Tamnoon.DOM.Node{
  selector_type:
    :id
    | :xpath
    | :from_string
    | :first_element
    | :last_element
    | :iteration_placeholder,
  selector_value: String.t() | Tamnoon.DOM.NodeCollection.t() | nil
}

Functions

@spec is_node?(node :: any()) :: boolean()
@spec new!(node :: term()) :: %Tamnoon.DOM.Node{
  selector_type: term(),
  selector_value: term()
}

Constructs a Tamnoon.DOM.Node.t/0 with the following arguments:

  • :selector_type – an atom (:id, :xpath, :from_string, :first_element, :last_element or :iteration_placeholder).

  • :selector_value – the value associated with the selector.