Meeseeks v0.7.6 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
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
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
Functions
next(t, Meeseeks.Document.node_t, Meeseeks.Document.t) :: [Meeseeks.Document.node_t] | Meeseeks.Document.node_t | nil
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.
Returns the combinator's selector.
Callbacks
next(combinator :: t, node :: Meeseeks.Document.node_t, document :: Meeseeks.Document.t) :: [Meeseeks.Document.node_t] | Meeseeks.Document.node_t | nil
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.
Invoked to return the combinator's selector.