Meeseeks v0.13.1 Meeseeks.Selector.Combinator behaviour View Source

Combinator structs package some method for finding related nodes and a Meeseeks.Selector to be run on found nodes.

For instance, the css selector ul > li contains the combinator > li, which roughly translates to "find a node's children and match any that are lis."

In Meeseeks, this combinator could be represented as:

alias Meeseeks.Selector.Combinator
alias Meeseeks.Selector.Element

%Combinator.ChildElements{
  selector: %Element{selectors: [%Element.Tag{value: "li"}]}}

When defining a combinator using use Meeseeks.Selector.Combinator, the default implementation of selector/1 expects the selector to be stored in field selector. If this is different in your struct, you must implement selector/1.

Examples

defmodule Selector.Combinator.Parent do
  use Meeseeks.Selector.Combinator

  defstruct selector: nil

  def next(_combinator, node, _document) do
    node.parent
  end
end

Link to this section Summary

Functions

Finds the node or nodes that a combinator wishes its selector to be run on

Returns the combinator's selector

Callbacks

Invoked in order to find the node or nodes that a combinator wishes its selector to be run on

Invoked to return the combinator's selector

Link to this section Types

Link to this section Functions

Finds the node or nodes that a combinator wishes its selector to be run on.

Returns the applicable node or nodes, or nil if there are no applicable nodes.

Link to this function

selector(combinator) View Source
selector(t()) :: Meeseeks.Selector.t()

Returns the combinator's selector.

Link to this section Callbacks

Link to this callback

next(combinator, node, document) View Source
next(
  combinator :: t(),
  node :: Meeseeks.Document.node_t(),
  document :: Meeseeks.Document.t()
) ::
  [Meeseeks.Document.node_t()] | Meeseeks.Document.node_t() | nil | no_return()

Invoked in order to find the node or nodes that a combinator wishes its selector to be run on.

Returns the applicable node or nodes, or nil if there are no applicable nodes.

Link to this callback

selector(combinator) View Source
selector(combinator :: t()) :: Meeseeks.Selector.t()

Invoked to return the combinator's selector.