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/[email protected]/bundles/datastar.js"></script>
Breaking changes:
- The attribute key delimiter has been changed from
-to:(data-signals-foobecomesdata-signals:foo,data-on-clickbecomesdata-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-loadattribute todata-init. - Renamed
.trailand.notrailmodifier arguments to.trailingand.notrailingrespectively. - 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-bindattribute on an input with typefilenow 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.kebabmakes$a2b--fooinstead 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-computedattribute. (#1053) - The
data-indicatorattribute now sets the signal tofalseeven if the signal has already been defined. - Fetch requests now respect URIs provided by a
basetag. (#1047) - Form fields are no longer validated if a
novalidateattribute exists on theformtag. (#1056) - Setting a signal to
nullorundefinednow actually deletes the signal. (#1058) - Attributes can now be used on the
htmlelement. - Attribute keys and aliases can now start with a non-letter (
data-signals:1fooordata-on:-foo). (#1030) - Fixed a bug in
data-bindwhen using namespaced signals as arrays. - Fixed a bug resulting in
data-ignore__selfnot being applied. (#1064) - Fixed a bug preventing the
__debounce.leadingmodifier from working. - Fixed a bug preventing the combination of
__debounceand__viewtransitionmodifiers from working. - Fixed a bug when using
autorequest cancellation where theFINISHEDfetch event would fire after theSTARTEDfetch event of the cancelling request.