bigskysoftware / bigskysoftware/htmx
Undocumented Behavior: `hx-boost` will honor any `hx-swap` attribute it found on the DOM tree
- Dominant language
- JavaScript
- Stars
- 49.4k
- Forks
- 1.7k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 30
Description
Hi, I hope this issue finds you well.
I just want to report a little bit of undocumented behavior as far as I can tell (at the very least, I don't think I found any mention of this specific behavior on [htmx.org/docs](https://htmx.org/docs/#boosting)).
The issue specifically is about the `hx-boost` behavior on an anchor tag. If on the way to the root/parent of the DOM, you find any `hx-swap` attribute, it will honor that attribute during swapping.
For example the following code:
```html
```
Will not swap the ``. But instead will append the `innerHTML` of the response body after the pre-existing body. like this:
```html
...
```
Just like the behavior of `afterend`.
This behavior can be fixed by specifying `hx-swap` attribute alongside the `hx-boost` to the default (`innerHTML`) or even similar behavior (such as `outerHTML`) like this:
```html
Title
```
However there does not seem to be any difference when using either `innerHTML` or `outerHTML`.
I won't exactly specify this as a bug, as it makes sense that `hx-boost` is in a way shared behavior with `hx-get`. Though it does not seem to be documented anywhere and it took me quite some time to identify this issue.
Hope that it helps. Thanks!!
Contributor guide
Research direction
Start with the htmx.org/docs/#boosting section mentioned in the issue and verify how hx-boost interacts with an inherited hx-swap attribute. Document the behavior with the provided example and explain the available override; done means the behavior is discoverable in the boosting documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100