Releases: starfederation/datastar
v1.0.0-RC.5
- The
data-on-*
attribute no longer requires that theisTrusted
property on the event istrue
for an expression to be executed. - The
data-on-load
attribute no longer wraps the expression insetTimeout
when no delay is provided. - Changed the
filterSignals
option in the backend actions to maintain the defaultinclude
andexclude
values 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-string
would merge in the path of the object rather than the object itself. - Removed the
__trusted
modifier.
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
, andbody
elements. - 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
__filter
modifier todata-query-string
that filters out empty values when syncing signals to query string params. - When a signal is predefined, its
type
is 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-persist
are now added asdata-persist-mykey
, and the__key
modifier has been removed. - Numeric signal names are now correctly parsed.
- Fixed a regression in which
data-attr
values were not being JSON encoded. - Fixed a bug in which
data-text
anddata-json-signals
would 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-load
would be applied ason-load
). - Fixed a bug in which the
retries-failed
event was namedretrying
. - Fixed a bug in which the
remove
mode would fail when patching elements if no elements were provided. - Fixed a bug in which
data-class
would 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
remove
mode 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-style
attribute that sets the value of inline CSS styles on an element based on an expression, and keeps them in sync. - Added a
requestCancellation
option to backend actions that controls request cancellation behavior. - Fixed a bug in which indicator signals were not being set to
false
after atext/html
response completed. - Fixed a bug in which a duplicate
text/event-stream
entry was being added to theAccept
header 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-attr
with 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-sse
event todatastar-fetch
.
v1.0.0-RC.1
Some plugins are now available under Datastar Pro, which adds functionality to the the free open source Datastar framework. These plugins are available under a commercial license that helps fund our open source work.
Of the many changes listed below, one major feature is that objects in signals are now reactive! This means that you can now create complex data structures in signals, and any changes to these objects will automatically propogate to expressions.
SSE event handling has also changed, in addition to all of the SDKs. Please refer to the SSE docs and each of the SDKs for the correct syntax to use.
- Objects in signals are now reactive, meaning that any changes to these objects will automatically propogate to expressions.
- Plugins are now reapplied on morph only if their values/keys/modifiers have changed.
- Added the ability for Datastar to receive
text/html
,application/json
, andtext/javascript
content types, that patch elements, patch signals, and execute JavaScript respectively. - Added a
data-effect
attribute that executes an expression when any of the signals it references change. - Added a
data-ignore-morph
attribute to thePatchElements
watcher that skips morphing the respective element and its children. - Added a
data-json-signals
attribute that sets the text content of an element to a reactive JSON stringified version of all signals. - Added a
data-on-signal-patch
attribute that executes an expression when a signal patch takes place. - Added a
data-on-signal-patch-filter
attribute for filtering the signals that cause the expression indata-on-signal-patch
to be executed. - Added a
data-preserve-attr
attribute that preserves the client side state of an attribute through a morph. - Added a
data-on-resize
attribute (PRO) that attaches a ResizeObserver to the element, and executes the expression each time the element’s dimensions change. - Added a
data-query-string
attribute (PRO) that syncs the query string with signal values, including optional history support. - Added a
datastar-upload-progress
event (PRO) for monitoring file upload progress. - Added a
filterSignals
option to SSE actions that filters the signals send to the backend based on include and exclude regular expressions. - Added a
__trusted
modifier to thedata-on
attribute, which runs the expression even if theisTrusted
property on the event isfalse
. - Added automatic request cancellation for SSE actions - when a new request is initiated on an element, any existing request on that same element is automatically cancelled.
- Removed the
abort
option from SSE actions as request cancellation is now handled automatically at the element level. - The URL passed into SSE actions (
@get
,@post
, etc.) is now treated as a relative URI. - The default
Content-Type
header sent withform
requests is nowapplication/x-www-form-urlencoded
. - The value of a clicked button element is now included in the request when using the
form
content type. - The
data-star-ignore
attribute has been renameddata-ignore
. - The
data-attr
attribute now renderstrue
as""
instead of"true"
(e.g.checked=""
instead ofchecked="true"
). - The
data-attr
attribute now preserves the string literals"false"
,"null"
, and"undefined"
when using a key. - Fixed a bug when using the
__debounce.leading
modifier with thedata-on
attribute. - Removed the
data-on-signal-change
attribute. Use the newdata-on-signal-patch
attribute instead. - Removed the
datastar-signal-change
event. Use the newdatastar-signal-patch
event instead. - Removed the
includeLocal
option in backend action requests. Use thefilterSignals
option instead. - Removed the variable
ctx
from data attributes. Use the newel
variable to access the element the attribute is attached to, use the new$
variable to access the signal root, or the newdata-json-signals
attribute to output all signals. - Removed support for adding a dollar sign prefix to signal names in the value of the
data-bind
,data-ref
, anddata-indicator
attributes. - Removed the auto generated IDs that were assigned to elements using data attributes.
Changes to SSE Event Handling
- Renamed the
datastar-merge-fragments
anddatastar-merge-signals
SSE events todatastar-patch-elements
anddatastar-patch-signals
respectively. - Renamed the
mergeMode
parameter of thedatastar-patch-elements
SSE event tomode
. - Renamed the
morph
mode toouter
. - Renamed the
outer
mode toreplace
. - The
inner
mode now morphs the element’s inner HTML. - Removed the
upsertAttributes
mode. - Added the
remove
mode. - The
datastar-patch-signals
SSE event now patches (adds/updates/removes) signals according to the JSON Merge Patch RFC 7396. - Removed the
RemoveFragments
,RemoveSignals
, andExecuteScript
watchers.
v1.0.0-beta.11
This release adds wildcard support to data-on-signals-change-*
, data-persist
, @setAll
and @toggleAll
using *
to match a single path segment and **
to match multiple path segments. Note that this does mean a potentially breaking change if you were relying on path prefixes.
The beta phase is now officially unofficially over, and the next release should be v1.0.0 🚀
Added
- Added the
__debounce
,__throttle
and__viewtransition
modifiers todata-on-intersect
. - Added the
__debounce
,__throttle
and__viewtransition
modifiers todata-on-signal-change
. - Added the
__viewtransition
modifier todata-on-interval
. - Added the
__viewtransition
modifier todata-on-load
. - Added the
__viewtransition
modifier todata-on-raf
.
Changed
- The
datastar-sse
event is now dispatched on thedocument
element, and usingdata-on-datastar-sse
automatically listens for the event on thedocument
(#802). - The
data-on-signals-change-*
attribute key now accepts a path in which*
matches a single path segment and**
matches multiple path segments (data-on-signals-change-foo.*.baz
,data-on-signals-change-foo.**
). - The
data-persist
attribute now accepts one or more space-separated paths in which*
matches a single path segment and**
matches multiple path segments (data-persist="foo.*.baz"
,data-persist="foo.**"
). - The
@setAll
action now accepts one or more space-separated paths in which*
matches a single path segment and**
matches multiple path segments (@setAll('foo.*.baz', true)
,@setAll('foo.**', true)
) (#793). - The
@toggleAll
action now accepts one or more space-separated paths in which*
matches a single path segment and**
matches multiple path segments (@toggleAll('foo.*.baz')
,@toggleAll('foo.**')
) (#793).
v1.0.0-beta.10
We’ve taken the opportunity to button up the API in preparation for the stable v1 release 🚀
Take note of the renamed attributes and the removal of the ability to use a key with data-persist
.
data-intersects
→ data-on-intersect
data-on-signals-change
→ data-on-signal-change
data-persist-*
→ data-persist
Added
- Added a
retries-failed
event type that is dispatched when the SSE plugin fails after retrying (#785).
Changed
- Updated Idiomorph to version 0.7.3.
- Renamed the
data-intersects
attribute todata-on-intersect
. - Renamed the
data-on-signals-change
attribute todata-on-signal-change
. - Classes used in
data-class-*
attributes now default to kebab-case (#761). - Events used in
data-on-*
attributes now default to kebab-case (#761). - The
datastar-sse
event is now dispatched on the element itself (#761). - The NPM package now also exports all plugins and bundles (#742).
- Data attributes with plugin names in their prefix are no longer processed (#771).
- The alias used in the aliased bundle has been renamed to
star
(data-star-*
) (#772).
Fixed
- Fixed the applying of plugins to give custom plugins a chance to load (#740).
- Fixed a bug in which the indicator signal was not being reset when the element it was on was removed from the DOM (#749).
- Fixed a bug in which merging multiple targets was not working correctly (#780).
Removed
- Removed the ability to use a key with the
data-persist
attribute. - Removed settling from SSE events, which has become redundant (#764).
v1.0.0-beta.9
Added
- Added the ability for all input elements to set bound signals to an array of values by predefining the signal as an array.
Fixed
- Fixed a bug in which
data-signals
was being reapplied each time any attribute changed on an element (#709). - Fixed a bug in which focus was not being restored to input elements after merging fragments (#710).
- Fixed a bug in which the
__delay
modifier was being ignored (#720). - Fixed a bug in which signals bound to text input elements with a
value
attribute were being reset to the value when the entered value was empty.
v1.0.0-beta.8
Added
- Added the ability for checkbox input elements to set bound signals to an array of values by predefining the signal as an array (#664).
Changed
- Updated Idiomorph to version 0.7.2.
- When using
data-bind
on an element, the signal value now defaults to the element’svalue
attribute, provided the signal has not already been defined (#687). - The expression passed into
data-on-signals-change
is no longer executed on page load (#682). - Whitespace is now maintained in merged fragments (#658).
- Attribute plugins now define a hash of their contents, preventing duplicate applies (#691).
- Attribute plugins are now applied to the
html
element instead of thebody
element (#691).
Fixed
- Fixed a bug in which
datastar-remove-fragments
events were not having any effect (#664). - Fixed a bug in which
datastarNaN
could be used as an auto-generated element ID (#679). - Fixed a bug in which
data-attr
was not removing the element attribute when using object syntax and the value wasfalse
(#693).
Removed
- Removed the Datastar class. The
apply
,load
, andsetAlias
functions are exported instead.