bigskysoftware / bigskysoftware/htmx

`htmx.config.requestClass` cannot contain a space i.e. cannot be multiple class names

Open
#2,852 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

My use case is I want to add a spinner to the initiating button when an `hx-post` occurs

The CSS framework I am using does that with TWO extra classes on buttons - `.spinner` AND `.spinner-(left|right)`

When I set `htmx.config.requestClass` to e.g. 'spinner spinner-right' thus:

```

```

it explodes:

```
Uncaught DOMException: Failed to execute 'add' on 'DOMTokenList': The token provided ('spinner spinner-right') contains HTML space characters, which are not valid in tokens.
at https://unpkg.com/htmx.org@2.0.2:1:29544
at se (https://unpkg.com/htmx.org@2.0.2:1:5402)
at Wt (https://unpkg.com/htmx.org@2.0.2:1:29460)
at he (https://unpkg.com/htmx.org@2.0.2:1:43160)
at https://unpkg.com/htmx.org@2.0.2:1:22304
at HTMLButtonElement.i (https://unpkg.com/htmx.org@2.0.2:1:21340)
```

You cannot combine classes under an umbrella 'super' class in CSS

I can't see a hook to tackle this will a custom extension, either

So I am stuck. Is there a way to do this? All I can do is watch the class changing on the element and add and remove styles manually per the existence of `.htmx-request`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.