Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hx-sync has cryptic elt is null errors on malformed values #2432

Open
egtann opened this issue Mar 25, 2024 · 1 comment
Open

hx-sync has cryptic elt is null errors on malformed values #2432

egtann opened this issue Mar 25, 2024 · 1 comment

Comments

@egtann
Copy link

egtann commented Mar 25, 2024

The error

In Firefox v124:

Uncaught TypeError: elt is null
    getInternalData https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:715
    issueAjaxRequest https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:4068
    processVerbs https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2525
    delayed https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2428
    setTimeout handler*eventListener https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2428
    addEventListener https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2443
    forEach https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:746
    addEventListener https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2366
    addTriggerHandler https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2577
    processVerbs https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2519
    processVerbs https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2518
    forEach https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:746
    processVerbs https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2512
    initNode https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2766
    processNode https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2804
    forEach https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:746
    processNode https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:2804
    <anonymous> https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:4875
    ready https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:4838
    htmx https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:4871
    <anonymous> https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js:4911

In Chromium v123:

htmx.js:715 Uncaught TypeError: Cannot read properties of null (reading 'htmx-internal-data')
    at getInternalData (htmx.js:715:19)
    at issueAjaxRequest (htmx.js:4068:17)
    at htmx.js:2525:13
    at htmx.js:2428:71

To Reproduce

<head>
    <script src="https://unpkg.com/htmx.org@2.0.0-beta1/dist/htmx.js"></script>
</head>
<input name="name" hx-post="" hx-trigger="input changed delay:500ms" hx-sync="abort"/>

Type anything into the input, wait 500ms, and you'll see the error.

Ideally the error would helpfully point you to the invalid hx-sync value that needs to change.

@egtann
Copy link
Author

egtann commented Mar 25, 2024

I neglected to read the docs. hx-sync needs a selector before the strategy, and it works fine. A nicer error indicating that the value in hx-sync is formatted incorrectly would have helped, so I'll leave this issue open for the possibility.

@egtann egtann changed the title hx-sync causes elt is null errors hx-sync has cryptic elt is null errors on malformed values Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant