Skip to content

Commit

Permalink
#36 test case
Browse files Browse the repository at this point in the history
  • Loading branch information
L3P3 committed Mar 29, 2022
1 parent 3586b45 commit 8189a1d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lui.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ const instance_render = (dom_parent, dom_first) => {
dom_last &&
dom_last.nextSibling !== dom_first
) {
VERBOSE && log('instance_reinsert ' + instance_name_get(child));
VERBOSE && log('instance_reinsert ' + key);
instance_reinsert(child, dom_parent, dom_first);
}

Expand Down
58 changes: 58 additions & 0 deletions test/app-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
hook_dom,
hook_memo,
hook_reducer,
init,
node_dom,
node_map
} from '../src/lui.js';

const ACTION_SWAP = 1;

const actions = [
// RESET
() => (
new Array(6).fill(null)
.map((_, i) => 'item_' + i)
),

// SWAP
state => [
state[0],
state[4],
state[2],
state[3],
state[1],
state[5],
],
];

const ListItem = ({
I,
}) => (
hook_dom('p', {innerText: I}), null
//[node_dom('p', {innerText: I})]
);

init(() => {
const [list, dispatch] = hook_reducer(actions);

return [
null,
[
hook_memo(() => (
node_dom('div', null, [
node_dom('button[innerText=swap]', {
onclick: () => {
dispatch(ACTION_SWAP);
},
}),
])
)),
node_map(
ListItem,
list
),
]
];
});

0 comments on commit 8189a1d

Please sign in to comment.