This release contains a syntax change to attributes that must be addressed manually before updating.
The recommended CDN link for Datastar is now version-locked to ensure safer updates and to avoid serving outdated cached files:
<script type="module" src="https://cdn.jsdelivr.net/gh/starfederation/datastar@1.0.0-RC.6/bundles/datastar.js"></script>
Breaking changes:
- The attribute key delimiter has been changed from
-
to:
(data-signals-foo
becomesdata-signals:foo
,data-on-click
becomesdata-on:click
, etc.), as allowed by the HTML Standard. The following regular expression can be used to update attributes.- Search:
data-(?!(on-(intersect|interval|load|raf|resize|signal-patch|signal-patch-filter)(_|=)))(attr|bind|class|computed|indicator|on|persist|ref|signals|style)-
- Replace:
data-$4:
- Search:
- Renamed the
data-on-load
attribute todata-init
. - Renamed
.trail
and.notrail
modifier arguments to.trailing
and.notrailing
respectively. - Removed file upload progress monitoring from Datastar Pro, which had limited browser support. It is recommended to use a file upload library instead, or wait for Rocket which will include a file upload web component. (#1049)
- Fetch requests are now cancelled when the element that initiated them is removed from the DOM. (#1045)
- The
data-bind
attribute on an input with typefile
now only creates one signal instead of{signalName}
,{signalName}Names
, and{signalName}Mimes
. The resultant type of the signal is{name: string, contents: string, mime: string}[]
. (#1041) - Camel casing no longer capitalizes after a number, and kebab casing now only preserves what was written in the attribute key (
data-signals:a2b--foo__case.kebab
makes$a2b--foo
instead of$a-2-b-foo
). (#1030)
Non-breaking changes:
- Datastar now supports all browsers that have support for ES2021. (#1037)
- Added support for using object syntax with the
data-computed
attribute. (#1053) - The
data-indicator
attribute now sets the signal tofalse
even if the signal has already been defined. - Fetch requests now respect URIs provided by a
base
tag. (#1047) - Form fields are no longer validated if a
novalidate
attribute exists on theform
tag. (#1056) - Setting a signal to
null
orundefined
now actually deletes the signal. (#1058) - Attributes can now be used on the
html
element. - Attribute keys and aliases can now start with a non-letter (
data-signals:1foo
ordata-on:-foo
). (#1030) - Fixed a bug in
data-bind
when using namespaced signals as arrays. - Fixed a bug resulting in
data-ignore__self
not being applied. (#1064) - Fixed a bug preventing the
__debounce.leading
modifier from working. - Fixed a bug preventing the combination of
__debounce
and__viewtransition
modifiers from working. - Fixed a bug when using
auto
request cancellation where theFINISHED
fetch event would fire after theSTARTED
fetch event of the cancelling request.