bigskysoftware / bigskysoftware/htmx

"hx-target did not match any element" warning is not logged if no `<body>` is present

Open
#4,006 2 comments 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

Showcase (this is a valid HTML5 document):

```html

Test

htmx.ajax('GET', '', 'div');

```

Logs:

```
Uncaught TypeError: Cannot read properties of null (reading 'isConnected')
```

Should log:

```
htmx: 'div' on hx-target did not match any element
Uncaught (in promise) Error: Target not found
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the HTML document and htmx.ajax('GET', '', 'div') example, then trace the target-resolution path that handles hx-target when no is present. Done means the missing target logs the hx-target warning and the subsequent Target not found error instead of an isConnected TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.