Fix DataStar v1 RC8 signal attribute incompatibilities
Two bugs that caused signals to not work on the frontend: 1. data-on-signal-change → data-on-signal-patch The data-on-signal-change attribute was removed in RC8. The replacement is data-on-signal-patch. 2. data-bind-newTodo="" → data-bind="newTodo" HTML normalises attribute names to lowercase at parse time, so data-bind-newTodo becomes data-bind-newtodo in the DOM. DataStar would then bind to signal $newtodo instead of $newTodo, breaking the two-way binding. The value syntax data-bind="newTodo" preserves the camelCase name correctly. https://claude.ai/code/session_01JThiQbp3Bn9J1VhBpRuz4u
This commit is contained in:
@@ -40,13 +40,15 @@ pub async fn todo_list(cx: &mut RenderContext) -> anyhow::Result<Markup> {
|
||||
}
|
||||
|
||||
// Add todo form.
|
||||
// data-bind-newTodo binds the input to the $newTodo signal.
|
||||
// The button uses new_todo.val ("$newTodo") in a DataStar expression.
|
||||
// data-bind="newTodo" binds the input to the $newTodo signal.
|
||||
// Value syntax is used instead of data-bind-newTodo because HTML
|
||||
// normalises attribute names to lowercase, which would corrupt the
|
||||
// camelCase signal name (newTodo → newtodo).
|
||||
div.add-form {
|
||||
input
|
||||
type="text"
|
||||
placeholder="What needs to be done?"
|
||||
data-bind-newTodo=""
|
||||
data-bind="newTodo"
|
||||
;
|
||||
button
|
||||
data-on-click="@post('/action/add_todo')"
|
||||
|
||||
Reference in New Issue
Block a user