Skip to content

Commit e17272a

Browse files
manwithacatclaude
andcommitted
docs: clarify next/previous selector scans whole DOM, not just siblings (#3430)
The parenthetical examples for `next <CSS selector>` and `previous <CSS selector>` described the result as the "closest following/previous sibling", but the actual behavior (correctly described in the surrounding sentence) is a forward/backward DOM scan that can match elements at any hierarchy level — not just siblings of the source element. Replaces "sibling" with "element" and adds a brief clarifying note in 10 places across 5 attribute and extension docs (hx-target, hx-trigger, hx-include, hx-disabled-elt, response-targets). No code change; only the parenthetical examples were misleading. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dbf77dd commit e17272a

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

www/content/attributes/hx-disabled-elt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ added to them for the duration of the request. The value of this attribute can b
1616
* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector
1717
* `next` which resolves to [element.nextElementSibling](https://developer.mozilla.org/docs/Web/API/Element/nextElementSibling)
1818
* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector
19-
(e.g. `next button` will disable the closest following sibling `button` element)
19+
(e.g. `next button` will disable the closest following `button` element — note this scans the whole DOM forward, not just siblings)
2020
* `previous` which resolves to [element.previousElementSibling](https://developer.mozilla.org/docs/Web/API/Element/previousElementSibling)
2121
* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.
22-
(e.g. `previous input` will disable the closest previous sibling `input` element)
22+
(e.g. `previous input` will disable the closest previous `input` element — note this scans the whole DOM backward, not just siblings)
2323

2424
Here is an example with a button that will disable itself during a request:
2525

www/content/attributes/hx-include.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ attribute can be:
1313
(e.g. `closest tr` will target the closest table row to the element).
1414
* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector.
1515
* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector.
16-
(e.g. `next .error` will target the closest following sibling element with `error` class)
16+
(e.g. `next .error` will target the next element with `error` class — note this scans the whole DOM forward, not just siblings)
1717
* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.
18-
(e.g. `previous .error` will target the closest previous sibling with `error` class)
18+
(e.g. `previous .error` will target the previous element with `error` class — note this scans the whole DOM backward, not just siblings)
1919

2020
Here is an example that includes a separate input value:
2121

www/content/attributes/hx-target.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ request. The value of this attribute can be:
1616
* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector.
1717
* `next` which resolves to [element.nextElementSibling](https://developer.mozilla.org/docs/Web/API/Element/nextElementSibling)
1818
* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector.
19-
(e.g. `next .error` will target the closest following sibling element with `error` class)
19+
(e.g. `next .error` will target the next element with `error` class — note this scans the whole DOM forward, not just siblings)
2020
* `previous` which resolves to [element.previousElementSibling](https://developer.mozilla.org/docs/Web/API/Element/previousElementSibling)
2121
* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.
22-
(e.g. `previous .error` will target the closest previous sibling with `error` class)
22+
(e.g. `previous .error` will target the previous element with `error` class — note this scans the whole DOM backward, not just siblings)
2323

2424

2525
Here is an example that targets a div:

www/content/attributes/hx-trigger.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ is seen again before the delay completes, it is ignored, the element will trigge
7171
* `find <CSS selector>` - finds the closest child matching the given css selector
7272
* `next` resolves to [element.nextElementSibling](https://developer.mozilla.org/docs/Web/API/Element/nextElementSibling)
7373
* `next <CSS selector>` scans the DOM forward for the first element that matches the given CSS selector.
74-
(e.g. `next .error` will target the closest following sibling element with `error` class)
74+
(e.g. `next .error` will target the next element with `error` class — note this scans the whole DOM forward, not just siblings)
7575
* `previous` resolves to [element.previousElementSibling](https://developer.mozilla.org/docs/Web/API/Element/previousElementSibling)
7676
* `previous <CSS selector>` scans the DOM backwards for the first element that matches the given CSS selector.
77-
(e.g. `previous .error` will target the closest previous sibling with `error` class)
77+
(e.g. `previous .error` will target the previous element with `error` class — note this scans the whole DOM backward, not just siblings)
7878
* `target:<CSS selector>` - allows you to filter via a CSS selector on the target of the event. This can be useful when you want to listen for
7979
triggers from elements that might not be in the DOM at the point of initialization, by, for example, listening on the body,
8080
but with a target filter for a child element

www/content/extensions/response-targets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ The value of each attribute can be:
1818
(e.g. `closest tr` will target the closest table row to the element).
1919
* `find <CSS selector>` which will find the first child descendant element that matches the given CSS selector.
2020
* `next <CSS selector>` which will scan the DOM forward for the first element that matches the given CSS selector.
21-
(e.g. `next .error` will target the closest following sibling element with `error` class)
21+
(e.g. `next .error` will target the next element with `error` class — note this scans the whole DOM forward, not just siblings)
2222
* `previous <CSS selector>` which will scan the DOM backwards for the first element that matches the given CSS selector.
23-
(e.g `previous .error` will target the closest previous sibling with `error` class)
23+
(e.g. `previous .error` will target the previous element with `error` class — note this scans the whole DOM backward, not just siblings)
2424

2525
## Installing
2626

0 commit comments

Comments
 (0)