Skip to content

Commit 5b69767

Browse files
author
sarutora
committed
changed keyed loop for anansi
1 parent 93b6f0a commit 5b69767

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

frameworks/keyed/anansi/js-framework-comps/src/.parsed/app.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ pub fn app_mount (_node_id : String) { anansi_aux :: APP_STATE . with (| a | { l
5757
let mut selected = _scope [0usize] . rf . borrow_mut () ;
5858
let selected = selected . downcast_mut :: < anansi_aux :: Signal < Option < usize > > > () . expect ("problem restoring variable") ;
5959
{ * selected . value_mut () = Some (* row . id ()) ;
60-
anansi_aux :: log ! ("{}" , selected . value () . unwrap ()) ;
6160
} } app_set_render () ;
6261
} fn app_on_click_7 () { { let mut _scope = anansi_aux :: lexical_scope () ;
6362
let _row = { let mut var = _scope [1usize] . rf . borrow_mut () ;
@@ -125,10 +124,7 @@ pub fn app_mount (_node_id : String) { anansi_aux :: APP_STATE . with (| a | { l
125124
_children . push (element ! ("TABLE" , attributes ! [("class" . to_string () , "table table-hover table-striped test-data" . to_string ()) ,] , { let mut _children = vec ! [] ;
126125
_children . push (element ! ("TBODY" , attributes ! [] , { let mut _children = vec ! [] ;
127126
_children . push (anansi_aux :: Rsx :: new_keyed ({ let mut _keys = vec ! [] ;
128-
let mut _children = vec ! [] ;
129-
for row in data . value_mut () . iter_mut () { _keys . push (row . id () . to_string ()) ;
130-
_children . push ({ let mut _children = vec ! [] ;
131-
_children . push (element ! ("TR" , attributes ! [("class" . to_string () , if * selected . value () == Some (* row . id ()) { "danger" } else { "" } . to_string ()) ,] , { let mut _children = vec ! [] ;
127+
for row in data . value_mut () . iter_mut () { _keys . push (element ! ("TR" , attributes ! [("key" . to_string () , anansi_aux :: html_escape (& format ! ("{}" , row . id ()))) , ("class" . to_string () , if * selected . value () == Some (* row . id ()) { "danger" } else { "" } . to_string ()) ,] , { let mut _children = vec ! [] ;
132128
_children . push (element ! ("TD" , attributes ! [("class" . to_string () , "col-md-1" . to_string ()) ,] , { let mut _children = vec ! [] ;
133129
_children . push (Rsx :: new_text (anansi_aux :: html_escape (& format ! ("{}" , row . id ())))) ;
134130
_children })) ;
@@ -145,9 +141,7 @@ pub fn app_mount (_node_id : String) { anansi_aux :: APP_STATE . with (| a | { l
145141
_children })) ;
146142
_children . push (element ! ("TD" , attributes ! [("class" . to_string () , "col-md-6" . to_string ()) ,] , { let mut _children = vec ! [] ;
147143
_children })) ;
148-
_children })) ;
149-
_children } . pop () . unwrap ()) ;
150-
} (_keys , _children) })) ;
144+
_children })) } _keys })) ;
151145
_children })) ;
152146
_children })) ;
153147
_children . push (element ! ("SPAN" , attributes ! [("class" . to_string () , "preloadicon glyphicon glyphicon-remove" . to_string ()) , ("aria-hidden" . to_string () , "true" . to_string ()) ,] , { let mut _children = vec ! [] ;
@@ -206,7 +200,9 @@ pub fn app_mount (_node_id : String) { anansi_aux :: APP_STATE . with (| a | { l
206200
<tbody>
207201
") ;
208202
for row in data . value_mut () . iter_mut () { _c . push_str ("
209-
<tr class=") ;
203+
<tr key=") ;
204+
_c . push_str (& anansi_aux :: html_escape (& format ! ("{}" , row . id ()))) ;
205+
_c . push_str (" class=") ;
210206
if * selected . value () == Some (* row . id ()) { _c . push_str ("
211207
") ;
212208
_c . push_str ("danger") ;

frameworks/keyed/anansi/js-framework-comps/src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ fn init() -> Rsx {
101101
</div></div>
102102
<table class="table table-hover table-striped test-data">
103103
<tbody>
104-
@keyed row, data.value_mut().iter_mut(), row.id() {
105-
<tr class=@if *selected.value() == Some(*row.id()) {
104+
@keyed row in data.value_mut().iter_mut() {
105+
<tr key=@row.id() class=@if *selected.value() == Some(*row.id()) {
106106
@:"danger"
107107
} else {
108108
@:""

frameworks/keyed/anansi/js-framework-wasm/pkg/js_framework_wasm.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,18 @@ function getImports() {
411411
const ret = getObject(arg0).attributes;
412412
return addHeapObject(ret);
413413
};
414+
imports.wbg.__wbg_removeAttribute_ad7a5bf2eed30373 = function() { return handleError(function (arg0, arg1, arg2) {
415+
getObject(arg0).removeAttribute(getStringFromWasm0(arg1, arg2));
416+
}, arguments) };
414417
imports.wbg.__wbg_setAttribute_79c9562d32d05e66 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
415418
getObject(arg0).setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
416419
}, arguments) };
417420
imports.wbg.__wbg_after_278d91be9294f30f = function() { return handleError(function (arg0, arg1) {
418421
getObject(arg0).after(getObject(arg1));
419422
}, arguments) };
423+
imports.wbg.__wbg_setdata_c26e68878a7d634c = function(arg0, arg1, arg2) {
424+
getObject(arg0).data = getStringFromWasm0(arg1, arg2);
425+
};
420426
imports.wbg.__wbg_after_99945dd558e3dc5e = function() { return handleError(function (arg0, arg1) {
421427
getObject(arg0).after(getObject(arg1));
422428
}, arguments) };
Binary file not shown.

0 commit comments

Comments
 (0)