(child)
JSX children selected by position or value
(child pos? val?)Where:
Matching:
- text children, e.g.
<Link>text</Link> - expression children, e.g.
<Link>{expr}</Link> - element children, e.g.
<Link><Icon /></Link>
Behavior
- With only a position,
(child N)matches elements that have a child at that position. - Without position or value,
(child)only matches elements that have at least one child.
Examples
Find components that render untranslated text directly.
(jsx _ _ (child _ (str /welcome|hello/i)))Selects in lines { 1, 3 } but not in { 2 }:
<Header>Welcome</Header>
<Header>{t("welcome")}</Header>
<Footer>Hello there</Footer>Identify buttons whose first child is an icon component.
(jsx Button _ (child 1 (jsx Icon)))Selects in lines { 1 } but not in { 2, 3 }:
<Button><Icon />Save</Button>
<Button>Save<Icon /></Button>
<Link><Icon />Save</Link>Extract all direct children of a list for inspection.
(jsx List _ (child _ (:into)))Selects in lines { 2, 2 } but not in { }:
<List>
<Item />
<Item />
</List>Arguments
pos
• Number
Does NOT support: Composition — Free-form Selection — Refinement — Replacement
val
• (:kind) • (:ref) • (:text) • (arr) • (attr) • (bool) • (call) • (child) • (comp) • (export) • (fun) • (id) • (id+) • (import) • (jsx) • (mem) • (null) • (num) • (obj) • (of) • (prop) • (regex) • (regex+) • (str) • (str*) • (str+) • (tpl) • (tpl*) • (var) • (:into) • (:and) • (:or) • (:not) • (:replace) • (:capture)