Skip to content

Websockets extension not working in Safari #2389

@artemgordinskiy

Description

@artemgordinskiy

Using HTMX v1.9.10 with the latest ws.js on Safari 17.4, I am unable to establish a websocket connection.
This works in every other browser I've tried it in.

Here is a reduced test case:
https://codepen.io/ArtemGordinsky/pen/vYMLPKG

<div hx-ext="ws" ws-connect="wss://echo.websocket.org">

Error trace from Safari:

[Error] TypeError: null is not an object (evaluating 'elt.hasAttribute')
hasAttribute — htmx.js:178
queryAttributeOnThisOrChildren — ws.js:451
onEvent — ws.js:58
(anonymous function) — htmx.js:2238
(anonymous function) — htmx.js:2202
forEach — htmx.js:405
withExtensions — htmx.js:2200
triggerEvent — htmx.js:2237
initNode — htmx.js:2110
(anonymous function) — htmx.js:2157
forEach — htmx.js:405
processNode — htmx.js:2157

Thread on Discord:
https://discord.com/channels/725789699527933952/1215734150934302770/1215734150934302770

I was also able to reproduce the issue with this test project:
https://github.com/chuhlomin/htmx-websockets

Has anyone else encountered this issue before?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions