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/javascriptcontent types, that patch elements, patch signals, and execute JavaScript respectively. - Added a
data-effectattribute that executes an expression when any of the signals it references change. - Added a
data-ignore-morphattribute to thePatchElementswatcher that skips morphing the respective element and its children. - Added a
data-json-signalsattribute that sets the text content of an element to a reactive JSON stringified version of all signals. - Added a
data-on-signal-patchattribute that executes an expression when a signal patch takes place. - Added a
data-on-signal-patch-filterattribute for filtering the signals that cause the expression indata-on-signal-patchto be executed. - Added a
data-preserve-attrattribute that preserves the client side state of an attribute through a morph. - Added a
data-on-resizeattribute (PRO) that attaches a ResizeObserver to the element, and executes the expression each time the element’s dimensions change. - Added a
data-query-stringattribute (PRO) that syncs the query string with signal values, including optional history support. - Added a
datastar-upload-progressevent (PRO) for monitoring file upload progress. - Added a
filterSignalsoption to SSE actions that filters the signals send to the backend based on include and exclude regular expressions. - Added a
__trustedmodifier to thedata-onattribute, which runs the expression even if theisTrustedproperty 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
abortoption 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-Typeheader sent withformrequests is nowapplication/x-www-form-urlencoded. - The value of a clicked button element is now included in the request when using the
formcontent type. - The
data-star-ignoreattribute has been renameddata-ignore. - The
data-attrattribute now renderstrueas""instead of"true"(e.g.checked=""instead ofchecked="true"). - The
data-attrattribute now preserves the string literals"false","null", and"undefined"when using a key. - Fixed a bug when using the
__debounce.leadingmodifier with thedata-onattribute. - Removed the
data-on-signal-changeattribute. Use the newdata-on-signal-patchattribute instead. - Removed the
datastar-signal-changeevent. Use the newdatastar-signal-patchevent instead. - Removed the
includeLocaloption in backend action requests. Use thefilterSignalsoption instead. - Removed the variable
ctxfrom data attributes. Use the newelvariable to access the element the attribute is attached to, use the new$variable to access the signal root, or the newdata-json-signalsattribute 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-indicatorattributes. - Removed the auto generated IDs that were assigned to elements using data attributes.
Changes to SSE Event Handling
- Renamed the
datastar-merge-fragmentsanddatastar-merge-signalsSSE events todatastar-patch-elementsanddatastar-patch-signalsrespectively. - Renamed the
mergeModeparameter of thedatastar-patch-elementsSSE event tomode. - Renamed the
morphmode toouter. - Renamed the
outermode toreplace. - The
innermode now morphs the element’s inner HTML. - Removed the
upsertAttributesmode. - Added the
removemode. - The
datastar-patch-signalsSSE event now patches (adds/updates/removes) signals according to the JSON Merge Patch RFC 7396. - Removed the
RemoveFragments,RemoveSignals, andExecuteScriptwatchers.