Skip to content

Comments

Update ws extension to use htmx.swap#3638

Merged
1cg merged 1 commit intobigskysoftware:fourfrom
MichaelWest22:ws-swap
Jan 29, 2026
Merged

Update ws extension to use htmx.swap#3638
1cg merged 1 commit intobigskysoftware:fourfrom
MichaelWest22:ws-swap

Conversation

@MichaelWest22
Copy link
Collaborator

Description

This possible change update the web socket extension to use htmx.swap as its swapping method instead of insertContent. This allows hx-partial tags and oob swaps to work as normal. Also the ws extension had a custom hx-partial format with id= attribute which did not match with the core htmx hx-partial design so I've updated the core htmx design to allow this natural id format which allows simple use cases like:

<hx-partial id="foo">New Inner Content</hx-partial>

which will just do a default innerHTML swap of the contents of the element with id foo.

This change allows most of the existing ws tests to remain as id only hx-partial's

There is one other breaking change and that is that before the swap style of the active element or from the JSON wrapper would set the default hx-partial swap style which is not how existing hx-partial normal works where each one is treated as innerHTML default and you have to be explicit in its swap method so that hx-partials are fully self contained.

Corresponding issue:

Testing

Updated tests.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

@MichaelWest22 MichaelWest22 added the htmx 4 Issues specific to htmx version 4 label Jan 28, 2026
Copy link

@stukennedy stukennedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

htmx 4 Issues specific to htmx version 4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants