We’ve overhauled Datastar in v0.21.0, doubling down on making nestable signals declarative. To that end, we’ve removed special characters, made the API more explicit and consistent, and fixed restrictions to nested signals that we discovered. Signal values are now accessed in expressions using the syntax signalName.value
, actions no longer have a prefix, and attribute keys support nested signals using dot-delimited paths.
The new Datastar VSCode extension and IntelliJ plugin have autocomplete for all v0.21.0 attributes, and we’ve painstakingly added error pages for every error that can be thrown.
Added
- Added the ability to merge one-off signals using the syntax
data-signals-foo="value"
. - Added the ability to use dot-delimited paths to denote nested signals in applicable attribute keys (
data-signals-foo.bar="value"
). - Added the ability to use multiple attributes using the syntax
data-attributes="{attrName1: value1, attrName2: value2}"
. - Added the ability to use a single classes using the syntax
data-class-hidden="foo.value"
. - Added the ability to use a key instead of a value to denote a signal name in the
data-bind
,data-indicator
anddata-ref
attributes (data-bind-foo
,data-indicator-foo
,data-ref-foo
). - Added error codes and links to descriptions in the console for every error thrown.
- Retries and backoff are now configurable for SSE connections.
Changed
- Signals no longer have the
$
prefix and must be acessed using a.value
suffix (signalName.value
). - Action plugins no longer have the
$
prefix. - Renamed the
data-store
attribute todata-signals
. - Renamed the
data-bind
attribute todata-attributes
. - Renamed the
data-model
attribute todata-bind
. - Changed the
data-*
attribute modifier delimiter from.
to__
for modifiers and from_
to.
for arguments. This is to be spec compliant while still parseable with new nested signal syntax (data-on-keydown__debounce.100ms__throttle.noLead="value"
). - The the
get()
,post()
,put()
,patch()
anddelete()
plugins have been replaced by a singlesse()
plugin that accepts a method as an option (sse(url, {method: 'post'})
), defaulting toget
. - The
setAll()
andtoggleAll
plugins now accept a path prefix, instead of a regular expression. - Nested signals no longer allow
__
in the key, which causes a conflict with modifiers.
Fixed
- Fixed headers not merging correctly.
- Fixed new lines in the SDK protocol for paths.