Releases: starfederation/datastar
Releases · starfederation/datastar
Release list
v1.0.2
- Added a
viewTransitionSelectordata line to SSE responses that specifies the CSS selector for the element to use for view transitions when patching elements. (#1154) - Changed the fetch abort controller to cancel in-flight requests with the same method and URL, regardless of the element that initiated the request. (#1166)
- Changed the default event for checkbox and radio inputs using
data-bindtoinputfor more immediate updates. - Optimized patch element handling for improved performance when only a single target is involved. (#1155)
- Fixed a bug in which the
data-bindattribute with a modifier was not working correctly for checkboxes with the signal set to an array. (#1159) - Fixed retry options for fetch actions to ensure that retries are attempted correctly when a request fails with a 5xx response. (#1161)
v1.0.1
- Made it so that the
__propand__eventmodifiers of thedata-bindattribute can be used independently of each other. - The prop value following the
__propmodifier of thedata-bindattribute is now converted to camel case. - Fixed a bug in
data-bindin which the signal type for aselectelement was being set to a number instead of a string when no initial value was set.
v1.0.0
Datastar 1.0 has finally shipped. We are done. Done like dinner. Watch the launch podcast.
- The payload is now resent when reconnecting after a tab visibility change when using the
fetchaction. (#1140) - The
Content-Type: application/jsonheader is now only set for requests that contain a body. (#1144) - A
bodyis now only sent for non-GET and non-DELETE requests. (#1144) - The
data-bindattribute now supports a__propmodifier that binds through a specific property instead of the inferred native/default binding. - The
data-bindattribute now supports an__eventmodifier that defines which events sync the element back to the signal. - The
data-bindattribute now respects the initial checked property of radio buttons. - The
data-onattribute now supports a__documentmodifier to attach event listeners to thedocumentelement. (#1151) - Improved morphing of
input,selectandtextareaelements. (#1075) - A new
datastar-prop-changeevent is now emitted instead of the nativechangeevent whenever a property is changed during morphing. - Improved the
kebabfunction to handle consecutive uppercase letters. - Fixed a bug in which the value of an input element with
type="submit"was not being included in form submissions. (#1150) - Fixed a bug in which the
__viewtransitionmodifier was interfering with other modifiers and event methods. (#1153) - Renamed the
retryMaxWaitMsbackend action option toretryMaxWaitfor consistency. - Rocket has been rewritten as a JavaScript API. See the new documentation at data-star.dev/reference/rocket.
v1.0.0-RC.8
- Added the
data-match-mediaDatastar Pro attribute that sets a signal totrueorfalsedepending on whether a media query matches, and keeps it in sync whenever the query changes. - Added the
@intlaction to Datastar Pro, for internationalized formatting of dates, numbers, and other values using the Intl namespace object. - Fetch requests with
requestCancellationset toautono longer cancel the request when the initiating element/attribute is removed from the DOM. Use thecleanupoption to opt in to that behavior. - Backend action requests now send the current state of the signals when retrying, rather than the initial state. (#900)
- Datastar expressions containing dollar sign symbols in string/template literals (e.g.
'$foo') are no longer parsed as signal references. (#1106) - The
datastar-patch-elementsevent now acceptsElementandDocumentFragmentpayloads and will consume/move them instead of re-parsing strings (non-string payloads are single-use and target only the first match). (#1125) - The
data-attrattribute now preserves function values. - Fixed a bug in the
data-onplugin in which event listeners were not cleared on element removal when using the__capturemodifier. - Fixed a bug in the
data-on-intersectplugin in which thethresholdmodifier was not properly applied.
v1.0.0-RC.7
- Added the
namespacedata line to thedatastar-patch-elementsevent, which makes it possible to patch elements usingsvgandmathmlnamespaces. (#1108) - Added the
retryoption to backend actions, whereautois the default behavior anderroris any4xxor5xxresponse. (#1073) - Added the
payloadoption to backend actions, which allows the fetch payload to be overridden. - Added an
__exitmodifier to thedata-on-intersectattribute to trigger the callback when the element exits the viewport. (#1011) - Added a
__thresholdmodifier to thedata-on-intersectattribute to specify a custom intersection threshold as a percentage. - Added the ability to have multiple cleanups per attribute.
- The
data-classattribute no longer runs its expression on cleanup. (#1060) - Backend actions now default to peeking signals so that no subscriptions are created. (#1100)
- Form fields are no longer validated if a
novalidateattribute exists on theformtag (for real, this time). (#1056) - Fetch requests are now cancelled when the any ancestor of the element that initiated them is removed from the DOM and the
requestCancellationoption is set toauto. (#1078, #1080) - The
openWhenHiddenoption for backend actions now defaults tofalseforGETrequests andtruefor all other HTTP methods. - Setting a signal to an object now merges the diff into the existing proxy rather than replacing it.
- Improved the handling of SVG elements when patching elements.
- Fixed a bug in which, when using the
throttlemodifier with atrailingargument, the expression was executed with the event from the leading edge of the throttle window rather than the last event. (#1091) - Fixed a bug in which duplicate requests were being made due to visibility changes. (#1096)
- Fixed a bug in which the
data-on-signal-patchattribute was not working when used with an alias.
v1.0.0-RC.6
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-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.
v1.0.0-RC.5
- The
data-on-*attribute no longer requires that theisTrustedproperty on the event istruefor an expression to be executed. - The
data-on-loadattribute no longer wraps the expression insetTimeoutwhen no delay is provided. - Changed the
filterSignalsoption in the backend actions to maintain the defaultincludeandexcludevalues if only one or the other is provided. - Fixed a bug in which setting the length of an array signal would cause errors when trying to access an element of the array.
- Fixed a bug in which
data-query-stringwould merge in the path of the object rather than the object itself. - Removed the
__trustedmodifier.
v1.0.0-RC.4
- Fixed a bug in which an input element being morphed would not have its value updated.
v1.0.0-RC.3
This release packs some new features, cleans up data-bind behavior, and fixes a rake of minor bugs.
- Added support for patching
html,head, andbodyelements. - Added support for patching arbitrary fragments into the DOM given a selector is provided.
- Added support for passing include and exclude filters in as strings.
- Added a
__filtermodifier todata-query-stringthat filters out empty values when syncing signals to query string params. - When a signal is predefined, its
typeis now preserved during binding – whenever the element’s value changes, the signal value is automatically converted to match the original type. - Custom keys in
data-persistare now added asdata-persist-mykey, and the__keymodifier has been removed. - Numeric signal names are now correctly parsed.
- Fixed a regression in which
data-attrvalues were not being JSON encoded. - Fixed a bug in which
data-textanddata-json-signalswould not reapply themselves after their text was changed. - Fixed a bug in which attributes that had a prefix with the same length as the alias would not be ignored (e.g.
data-option-loadwould be applied ason-load). - Fixed a bug in which the
retries-failedevent was namedretrying. - Fixed a bug in which the
removemode would fail when patching elements if no elements were provided. - Fixed a bug in which
data-classwould enter an infinite loop if there were multiple such attributes on the same element. - Fixed a bug in which attribute plugins on child elements were not cleaned up when removed.
- Removed support for using the ID of a provided element as a selector for the
removemode when patching elements. - Changed the behavior of how input values are diffed when morphed:
| Old input value | New input value | Behavior |
|---|---|---|
null |
null |
preserve old input value |
| some value | the same value | preserve old input value |
| some value | null |
set old input value to "" |
null |
some value | set old input value to new input value |
| some value | some other value | set old input value to new input value |
v1.0.0-RC.2
- Added a
data-styleattribute that sets the value of inline CSS styles on an element based on an expression, and keeps them in sync. - Added a
requestCancellationoption to backend actions that controls request cancellation behavior. - Fixed a bug in which indicator signals were not being set to
falseafter atext/htmlresponse completed. - Fixed a bug in which a duplicate
text/event-streamentry was being added to theAcceptheader in SSE actions. - Fixed a bug in which assigning a computed to an already existing signal would create a signal of a computed instead of a computed.
- Fixed a bug in which using
data-attrwith a key would observe the result of the expression rather than the key. - Fixed a bug in which signal names were being incorrectly parsed in some edge-cases.
- Renamed the
datastar-sseevent todatastar-fetch.