Meeseeks v0.7.1 Meeseeks.Selector.Combinator behaviour

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

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

Types

t()
t() :: struct

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.

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

Returns the combinator's selector.

Callbacks

next(combinator, node, document)

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.

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

Invoked to return the combinator's selector.