Change8

v4.0.0

Breaking Changes
📦 htmxView on GitHub →
4 breaking24 features🐛 31 fixes🔧 18 symbols

Summary

This release introduces significant new features like ETags support, a Websocket extension, and advanced `hx-boost` overrides, alongside numerous bug fixes and improvements to existing functionalities like Morph and SSE handling. Several internal refactors, such as moving the tokenizer and extracting the SSE extension, may require migration steps for existing extensions.

⚠️ Breaking Changes

  • The tokenizer has been moved from `find` to `parseConfig` for all operations. This may affect extensions that relied on the previous tokenizer location.
  • The `+` operator for merging `hx-config` has been removed. Use the new `mergeConfig` support instead.
  • The SSE extension has been extracted from the core into a standalone extension. This might require updates for projects directly using the SSE functionality from the core.
  • The `findAllExt` function now returns `this` for any inheritance level, which might break extensions expecting a different return type.

Migration Steps

  1. Update extensions that relied on the tokenizer's previous location in `find` to use `parseConfig` instead.
  2. Replace usage of the `+` operator for merging `hx-config` with the new `mergeConfig` functionality.
  3. If directly using SSE functionality from the core, migrate to the new standalone SSE extension.
  4. Review extensions that use `findAllExt` to ensure compatibility with the change in return type (now always returns `this`).

✨ New Features

  • Added ETags support for caching.
  • Introduced a new Websocket extension for HTMX.
  • Implemented `hx-custom` template tag support.
  • Added `hx-target`, `hx-source`, and `hx-request-type` headers.
  • Allowed string swapSpecs in `insertContent`.
  • Added `findall` functionality and fixed `find`.
  • Implemented advanced `hx-boost` overrides.
  • Added `mergeConfig` support.
  • Added Morph skip support for web components.
  • Added `textContent` swap style.
  • Improved WebSocket extension with `hx-ws` improvements.
  • Improved Morph exact node matching with scan ahead.
  • Added `hx-preserve` support for cases where no ID is found.
  • Added response URL pushing.
  • Added proper `newContent` handling in `insertContent`.
  • Introduced Upsert swap extension.
  • Added script tag processing in `swapWithHtmx` function.
  • Added tests for WebSocket script tag processing.
  • WebSocket extension now handles non-JSON messages as raw HTML with a cancelable event.
  • Added focus restoration support.
  • Added Alpine compatibility extension.
  • Partials now fall back to use transition default.
  • Added handling for empty non-GET actions.
  • Added handling for `newContent` processing of `outerMorph` that inserts new nodes.

🐛 Bug Fixes

  • Fixed select, strip, and title handling.
  • Ensured window context binding for Firefox compatibility.
  • Attribute values now return as strings again.
  • Optimized OOB and fixed partial tests.
  • Fixed bug in `hx-config` setting the wrong level for `+` merge.
  • Fixed up `handle swap` extension point and documentation.
  • Replaced state on initial state load.
  • Fixed title not being decoded on boost (e.g., "&lt;/&gt; htmx" instead of "</> htmx").
  • Fixed bug with empty response after partial removal detection.
  • Fixed missing target/swap via envelope and fixed re-connection tests.
  • Fixed `hx-validate` to respect `noValidate` and validate inputs outside of the form.
  • Improved `hx-boost` advanced config to use new `mergeConfig` for nesting.
  • Fixed morph cleanup of textNodes.
  • Fixed closing tags for `hx-partial` in `htmx-4.md`.
  • Fixed bug with empty response after partial removal detection.
  • Fixed missing target/swap via envelope and fixed re-connection tests.
  • Fixed `hx-validate` to respect `noValidate` and validate inputs outside of the form.
  • Improved `hx-boost` advanced config to use new `mergeConfig` for nesting.
  • Fixed morph cleanup of textNodes.
  • Fixed closing tags for `hx-partial` in `htmx-4.md`.
  • Fixed bug with empty response after partial removal detection.
  • Fixed missing target/swap via envelope and fixed re-connection tests.
  • Fixed `hx-validate` to respect `noValidate` and validate inputs outside of the form.
  • Improved `hx-boost` advanced config to use new `mergeConfig` for nesting.
  • Fixed morph cleanup of textNodes.
  • Fixed closing tags for `hx-partial` in `htmx-4.md`.
  • Fixed morph error with empty id attributes.
  • Fixed iOS Safari SSE disconnect on background.
  • Fixed Firefox not handling script tags in templates.
  • Improved Morph matching.
  • Fixed history restore to always use `innerHTML`.

Affected Symbols