Liking cljdoc? Tell your friends :D

reacl2.test-util.xpath

cljs

An xpath is basically a convenient and compositional way to define a filter function on nodes in a virtual DOM tree, resp. the React test renderer tree, roughly based on a 'path' through the tree.

The functions select, select-all, select-one and contains? apply that filter, starting from a specific context node.

For example:

(require [reacl2.test-util.xpath :as xp :include-macros true])

(>> / ** "div" [xp/text (xp/is= "Hello")])

matches on all div elements anywhere below the context node, that have a text content equal to "Hello".

(>> / my-class / "span" [:id (xp/is= "foo")])

matches on all span children of instances of the class my-class below the context node, that have the id "foo".

(>> my-class [xp/args (xp/is? = [42])])

matches the context node, if it is an instance of my-class and if its argument vector equals [42].

(>> / "span" [xp/first])

matches the first span element below the context node.

An xpath is basically a convenient and compositional way to define
  a filter function on nodes in a virtual DOM tree, resp. the React
  test renderer tree, roughly based on a 'path' through the tree.

  The functions [[select]], [[select-all]], [[select-one]]
  and [[contains?]] apply that filter, starting from a specific
  _context node_.

  For example:

```
(require [reacl2.test-util.xpath :as xp :include-macros true])

(>> / ** "div" [xp/text (xp/is= "Hello")])
```

  matches on all `div` elements anywhere below the context node, that have a text content equal to `"Hello"`.

```
(>> / my-class / "span" [:id (xp/is= "foo")])
```

  matches on all `span` children of instances of the class `my-class` below the context node, that have the id `"foo"`.

```
(>> my-class [xp/args (xp/is? = [42])])
```

  matches the context node, if it is an instance of `my-class` and if its argument vector equals `[42]`.

```
(>> / "span" [xp/first])
```

  matches the first span element below the context node.
raw docstring

>>cljmacro

(>> & forms)

Compose the given xpath selector forms to a combined selector, where from left to right, the selectors restrict the selection further. Special selector forms are:

  • / selects the the immediate children.

  • . selects/keeps the current node (will only rarely be needed).

  • .. selects the parent node.

  • ... selects the root node.

  • ** selects the current node and all its children and grand children.

  • [x y] filters as with (where (>> x y))

Any other form should evaluate to a selector as with comp.

For example (>> / **) selects the children and all grand children from the current node.

Compose the given xpath selector forms to a combined selector, where from left to right, the selectors restrict the selection further. Special selector forms are: 

- `/` selects the the immediate children.
- `.` selects/keeps the current node (will only rarely be needed).
- `..` selects the parent node.
- `...` selects the root node.
- `**` selects the current node and all its children and grand children.

- `[x y]` filters as with `(where (>> x y))`

Any other form should evaluate to a selector as with [[comp]].

For example `(>> / **)` selects the children and all grand children from the current node.
sourceraw docstring

allcljs

Selects the current node and all of its children and grand children. When using the composition macro >>, the literal ** is translated into this.

Selects the current node and all of its children and
grand children. When using the composition macro [[>>]], the literal
`**` is translated into this.
sourceraw docstring

andcljs

(and & selectors)

Selects the nodes that all of the given selectors selects.

Selects the nodes that all of the given selectors selects.
sourceraw docstring

app-statecljs

Selects the app-state if the current node is a Reacl component that has one.

Selects the app-state if the current node is a Reacl component that has one.
sourceraw docstring

argscljs

Selects the argument vector if the current node is a Reacl component.

Selects the argument vector if the current node is a Reacl component.
sourceraw docstring

attrcljs

(attr name)

Selects the value of an attribute name from virtual dom nodes. As a convience, a simple keyword k is translated into (attr k).

Selects the value of an attribute `name` from virtual dom nodes. As a convience, a simple keyword `k` is translated into `(attr k)`.
sourceraw docstring

childrencljs

Selects the children of the current node. When using the composition macro >>, the literal / is translated into this.

Selects the children of the current node. When using the
composition macro [[>>]], the literal `/` is translated into this.
sourceraw docstring

classcljs

(class c)

Selects only those nodes that are an instance of the given Reacl or React class c.

Selects only those nodes that are an instance of the given Reacl or React class `c`.
sourceraw docstring

class?cljs

Selects only those nodes that are a virtual component of any class type.

Selects only those nodes that are a virtual component of any class type.
sourceraw docstring

compcljs

(comp & selectors)

Compose the given xpath selector forms to a combined selector, where from left to right, the selectors restrict the filter further.

Valid selectors are all the primitives from this module, as well as:

  • strings stand for a virtual dom node as with tag,
  • keywords stand for attribute names as with attr,
  • Reacl classes stand for a selection by that class as with class

Also see >> for a convenience macro version of this.

Compose the given xpath selector forms to a combined
selector, where from left to right, the selectors restrict the filter
further. 

Valid selectors are all the primitives from this module,
as well as:

- strings stand for a virtual dom node as with [[tag]],
- keywords stand for attribute names as with [[attr]],
- Reacl classes stand for a selection by that class as with [[class]]

Also see [[>>]] for a convenience macro version of this.
sourceraw docstring

contains?cljs

(contains? node selector)

Returns if the given selector selects anything in the given node, i.e. if the result of select-all would be not-empty.

Returns if the given `selector` selects anything in the given `node`, i.e. if the result of [[select-all]] would be not-empty.
sourceraw docstring

count=cljs

(count= n)

Keeps the current selection, if it contains the given number of nodes.

Keeps the current selection, if it contains the given number of nodes.
sourceraw docstring

css-class?cljs

(css-class? s)

Keeps the current node only if it has a :class attribute matching with the given s. If s is a string or sequence, then the node must have all those classes in the same order. If s is a set of strings, then it must have all those classes in any order.

Keeps the current node only if it has a `:class` attribute
matching with the given `s`. If `s` is a string or sequence, then
the node must have all those classes in the same order. If `s` is a
set of strings, then it must have all those classes in any order.
sourceraw docstring

firstcljs

Select nodes that are the first child of their parent.

Select nodes that are the first child of their parent.
sourceraw docstring

first-wherecljs

(first-where sel)

Selects those nodes that are selected by the given selector, and for those that are not, the children are tried recursively.

Selects those nodes that are selected by the given selector, and for those that are not, the children are tried recursively.
sourceraw docstring

id=cljs

(id= v)

Keeps the current node only if it has an attribute id equal to v.

Keeps the current node only if it has an attribute `id` equal to `v`.
sourceraw docstring

is=cljs

(is= v)

Keeps the current node only if it is equal to v.

Keeps the current node only if it is equal to `v`.
sourceraw docstring

is?cljs

(is? pred & args)

Keeps the current node only if (pred node & args) holds.

Keeps the current node only if `(pred node & args)` holds.
sourceraw docstring

keycljs

Selects the key property of the nodes, if they have one.

Selects the key property of the nodes, if they have one.
sourceraw docstring

lastcljs

Select nodes that are the last child of their parent.

Select nodes that are the last child of their parent.
sourceraw docstring

local-statecljs

Selects the local-state if the current node is a Reacl component.

Selects the local-state if the current node is a Reacl component.
sourceraw docstring

notcljs

(not sel)

Selects those nodes that are not selected by the given selectors.

Selects those nodes that are not selected by the given selectors.
sourceraw docstring

nthcljs

(nth n)

Select nodes that are the nth child, starting at index 0.

Select nodes that are the nth child, starting at index 0.
sourceraw docstring

nth-lastcljs

(nth-last n)

Select nodes that are the "nth but last" child.

Select nodes that are the "nth but last" child.
sourceraw docstring

orcljs

(or & selectors)

Selects the nodes that any of the given selectors selects.

Selects the nodes that any of the given selectors selects.
sourceraw docstring

parentcljs

Selects the parent of the current node. When using the composition macro >>, the literal .. is translated into this.

Selects the parent of the current node. When using the
composition macro [[>>]], the literal `..` is translated into this.
sourceraw docstring

rangecljs

(range from to)

Selects nodes based on their position in the children list of their parent, starting at index from (inclusive) up to index to (exclusive). Both from and to can be negative meaning a position from the end of the children list. A 0 in from means the start of the list, but a 0 in to stands for the end of list, resp. one behind. So (range 0 0) selects the full list of children, (range 1 -1) selects all but the first and the last and (range -1 0) only the last child.

Selects nodes based on their position in the children list of their
parent, starting at index `from` (inclusive) up to index
`to` (exclusive). Both `from` and `to` can be negative meaning a
position from the end of the children list. A 0 in `from` means the
start of the list, but a 0 in `to` stands for the end of list,
resp. one behind. So `(range 0 0)` selects the full list of
children, `(range 1 -1)` selects all but the first and the
last and `(range -1 0)` only the last child.
sourceraw docstring

re-matches?cljs

(re-matches? regex)

Keeps the current node only if it is matches the given regex.

Keeps the current node only if it is matches the given `regex`.
sourceraw docstring

rootcljs

Select the root of the node tree. When using the composition macro >>, the literal ... is translated into this.

Select the root of the node tree. When using the composition macro [[>>]], the literal `...` is translated into this.
sourceraw docstring

selectcljs

(select node selector)

Returns the node selected by selector in the given node, or throws if there is more than one, or returns nil otherwise.

Returns the node selected by `selector` in the given `node`, or throws if there is more than one, or returns `nil` otherwise.
sourceraw docstring

select-allcljs

(select-all node selector)

Returns all nodes selected by selector in the given node.

Returns all nodes selected by `selector` in the given `node`.
sourceraw docstring

select-onecljs

(select-one node selector)

Returns the node selected by selector in the given node, or throws if there is none or more than one.

Returns the node selected by `selector` in the given `node`, or throws if there is none or more than one.
sourceraw docstring

selfcljs

Selects the current node. This the identity element of composing selects with comp.

Selects the current node. This the identity element of composing selects with [[comp]].
sourceraw docstring

style?cljs

(style? style)

Keeps the current node only if it has a :style attribute, which matches with all styles given in the map style. Note that it's ok if it has more styles.

Keeps the current node only if it has a `:style`
attribute, which matches with all styles given in the map `style`. Note
that it's ok if it has more styles.
sourceraw docstring

tagcljs

(tag type)

Selects only those nodes that are a virtual dom element of the given string type.

Selects only those nodes that are a virtual dom element of the given string `type`.
sourceraw docstring

tag?cljs

Selects only those nodes that are a virtual dom element of any tag type.

Selects only those nodes that are a virtual dom element of any tag type.
sourceraw docstring

textcljs

Selects the child nodes of type 'text'.

Selects the child nodes of type 'text'.
sourceraw docstring

text=cljs

(text= s)

Selects the nodes where the text content is equal to the given string.

Selects the nodes where the text content is equal to the given string.
sourceraw docstring

typecljs

(type t)

Selects those nodes that either of the given dom tag type, or the given Reacl or React class.

Selects those nodes that either of the given dom tag type, or the given Reacl or React class.
sourceraw docstring

voidcljs

A selector that drops everything, making a selection empty.

A selector that drops everything, making a selection empty.
sourceraw docstring

wherecljs

(where sel)

Selects the nodes for which the given selector would result in a non-empty list of nodes. When using the composition macro >>, a vector literal is translated into this.

Selects the nodes for which the given selector would result in a
non-empty list of nodes. When using the composition macro [[>>]], a
vector literal is translated into this.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close