Meeseeks.Selector.Combinator behaviour (Meeseeks v0.17.0) 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
li
s."
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
Specs
t() :: struct()
Link to this section Functions
Specs
next(t(), Meeseeks.Document.node_t(), Meeseeks.Document.t()) :: [Meeseeks.Document.node_t()] | Meeseeks.Document.node_t() | nil | no_return()
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.
Specs
selector(t()) :: Meeseeks.Selector.t()
Returns the combinator's selector.
Link to this section Callbacks
Specs
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.
Specs
selector(combinator :: t()) :: Meeseeks.Selector.t()
Invoked to return the combinator's selector.