Skip to content

Commit cb639a0

Browse files
committed
fix swap operation
1 parent c69684f commit cb639a0

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

frameworks/keyed/uhydro/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/uhydro/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/uhydro/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-framework-benchmark-uhydro",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "uhydro demo",
55
"main": "dist/app.min.js",
66
"js-framework-benchmark": {
@@ -27,6 +27,6 @@
2727
"typescript": "^4.3.2"
2828
},
2929
"dependencies": {
30-
"uhydro": "^1.0.5"
30+
"uhydro": "^1.0.6"
3131
}
3232
}

frameworks/keyed/uhydro/src/app.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, reactive, view, render, observe, getValue, swap } from "uhydro";
1+
import { h, reactive, view, render, observe, getValue } from "uhydro";
22

33
declare global {
44
namespace JSX {
@@ -161,7 +161,7 @@ view("tbody", data, (item) => {
161161
const className = reactive<"" | "danger">("");
162162

163163
const tr = (
164-
<tr class={className}>
164+
<tr class={className} data-bind>
165165
<td class="col-md-1">{item.id}</td>
166166
<td class="col-md-4">
167167
<a onclick={() => selected(item.id)}>{item.label}</a>
@@ -212,10 +212,15 @@ function update() {
212212
}
213213
function swapRows() {
214214
const d = getValue(data);
215-
swap(d[1], d[998]);
215+
if (d.length > 998) {
216+
const tmp = d[1];
217+
//@ts-ignore
218+
d[1](d[998]);
219+
//@ts-ignore
220+
d[998](tmp);
221+
}
216222
}
217223
function remove(id: number) {
218-
//@ts-ignore
219224
const copy = [...getValue(data)];
220225

221226
const index = copy.findIndex((i: typeof data[number]) => i?.id === id);

0 commit comments

Comments
 (0)