@@ -20,7 +20,7 @@ import { Todo } from "~/types";
2020
2121declare module "solid-js" {
2222 namespace JSX {
23- interface ExplicitProperties { }
23+ interface ExplicitProperties { }
2424 }
2525}
2626const setFocus = ( ) => ( el : HTMLElement ) => setTimeout ( ( ) => el . focus ( ) ) ;
@@ -91,41 +91,41 @@ export default function TodoApp(props: RouteSectionProps) {
9191 < ul class = "todo-list" >
9292 < For each = { filterList ( todos ( ) ) } >
9393 { todo => {
94- const togglingTodo = useSubmission ( toggleTodo , input => input [ 0 ] == todo . id ) ;
95- const editingTodo = useSubmission ( editTodo , input => input [ 0 ] == todo . id ) ;
96- const title = ( ) => ( editingTodo . pending ? editingTodo . input [ 0 ] : todo . title ) ;
94+ const togglingTodo = useSubmission ( toggleTodo , input => input [ 0 ] == todo ( ) . id ) ;
95+ const editingTodo = useSubmission ( editTodo , input => input [ 0 ] == todo ( ) . id ) ;
96+ const title = ( ) => ( editingTodo . pending ? editingTodo . input [ 0 ] : todo ( ) . title ) ;
9797 const pending = ( ) =>
9898 togglingAll . pending || togglingTodo . pending || editingTodo . pending ;
9999 const completed = ( ) =>
100100 togglingAll . pending
101101 ? ! togglingAll . input [ 0 ]
102102 : togglingTodo . pending
103- ? ! todo . completed
104- : todo . completed ;
105- const removing = ( ) => removingTodo . some ( data => data . input [ 0 ] === todo . id ) ;
103+ ? ! todo ( ) . completed
104+ : todo ( ) . completed ;
105+ const removing = ( ) => removingTodo . some ( data => data . input [ 0 ] === todo ( ) . id ) ;
106106 return (
107107 < Show when = { ! removing ( ) } >
108108 < li
109109 class = { [ "todo" , {
110- editing : editingTodoId ( ) === todo . id ,
110+ editing : editingTodoId ( ) === todo ( ) . id ,
111111 completed : completed ( ) ,
112- pending : pending ( ) ,
112+ pending : pending ( ) ?? false ,
113113 } ] }
114114 >
115115 < form class = "view" method = "post" >
116116 < button
117- formAction = { toggleTodo . with ( todo . id ) }
117+ formaction = { toggleTodo . with ( todo ( ) . id ) }
118118 class = "toggle"
119119 disabled = { pending ( ) }
120120 >
121- { completed ( ) ? < CompleteIcon /> : < IncompleteIcon /> }
121+ < Show when = { completed ( ) } fallback = { < IncompleteIcon /> } > < CompleteIcon /> </ Show >
122122 </ button >
123- < label onDblClick = { [ setEditing , { id : todo . id , pending } ] } > { title ( ) } </ label >
124- < button formAction = { removeTodo . with ( todo . id ) } class = "destroy" />
123+ < label onDblClick = { [ setEditing , { id : todo ( ) . id , pending } ] } > { title ( ) } </ label >
124+ < button formaction = { removeTodo . with ( todo ( ) . id ) } class = "destroy" />
125125 </ form >
126- < Show when = { editingTodoId ( ) === todo . id } >
126+ < Show when = { editingTodoId ( ) === todo ( ) . id } >
127127 < form
128- action = { editTodo . with ( todo . id ) }
128+ action = { editTodo . with ( todo ( ) . id ) }
129129 method = "post"
130130 onSubmit = { e => {
131131 e . preventDefault ( ) ;
@@ -135,9 +135,9 @@ export default function TodoApp(props: RouteSectionProps) {
135135 < input
136136 name = "title"
137137 class = "edit"
138- value = { todo . title }
138+ value = { todo ( ) . title }
139139 onBlur = { e => {
140- if ( todo . title !== e . currentTarget . value ) {
140+ if ( todo ( ) . title !== e . currentTarget . value ) {
141141 e . currentTarget . form ! . requestSubmit ( ) ;
142142 } else setTimeout ( ( ) => setEditing ( { } ) ) ;
143143 } }
@@ -154,7 +154,7 @@ export default function TodoApp(props: RouteSectionProps) {
154154 { sub => (
155155 < li class = "todo pending" >
156156 < div class = "view" >
157- < label > { String ( sub . input [ 0 ] . get ( "title" ) ) } </ label >
157+ < label > { String ( sub ( ) . input [ 0 ] . get ( "title" ) ) } </ label >
158158 < button disabled class = "destroy" />
159159 </ div >
160160 </ li >
@@ -198,6 +198,6 @@ export default function TodoApp(props: RouteSectionProps) {
198198 </ Show >
199199 </ footer >
200200 </ Show >
201- </ section >
201+ </ section >
202202 ) ;
203203}
0 commit comments