Skip to content

Commit 5bec6dc

Browse files
committed
optimize init
1 parent 9e807dd commit 5bec6dc

File tree

5 files changed

+113
-58
lines changed

5 files changed

+113
-58
lines changed

frameworks/keyed/million/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"js-framework-benchmark": {
1818
"frameworkVersionFromPackage": "million",
19-
"customURL": "/dist"
19+
"customURL": "/dist",
20+
"frameworkHomeURL": "https://github.com/aidenybai/million"
2021
}
2122
}

frameworks/keyed/million/src/main.js

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { withKey } from '../../../../../million/packages/block/block';
12
import {
23
Block,
34
fragment,
45
stringToDOM,
6+
linkEvent,
57
} from '/Users/aidenybai/Projects/aidenybai/million/packages/block/index';
68

79
const adjectives = [
@@ -69,7 +71,6 @@ let main;
6971

7072
const clear = () => {
7173
list = [];
72-
main.children = [];
7374
main.remove();
7475
};
7576

@@ -148,7 +149,7 @@ const Row = (() => {
148149
path: [0],
149150
edits: [
150151
{
151-
type: 2,
152+
type: 'child',
152153
hole: 'id',
153154
index: 0,
154155
},
@@ -159,13 +160,13 @@ const Row = (() => {
159160
path: [1, 0],
160161
edits: [
161162
{
162-
type: 3,
163+
type: 'event',
163164
listener: 'select',
164165
name: 'onClick',
165166
hole: 'select',
166167
},
167168
{
168-
type: 2,
169+
type: 'child',
169170
hole: 'label',
170171
index: 0,
171172
},
@@ -176,7 +177,7 @@ const Row = (() => {
176177
path: [2, 0],
177178
edits: [
178179
{
179-
type: 3,
180+
type: 'event',
180181
listener: 'remove',
181182
name: 'onClick',
182183
hole: 'remove',
@@ -188,7 +189,7 @@ const Row = (() => {
188189
path: [],
189190
edits: [
190191
{
191-
type: 0,
192+
type: 'attribute',
192193
hole: 'className',
193194
name: 'class',
194195
},
@@ -197,7 +198,10 @@ const Row = (() => {
197198
},
198199
];
199200
const shouldUpdate = (oldProps, newProps) => {
200-
return oldProps.$key !== newProps.$key;
201+
return (
202+
oldProps.label !== newProps.label ||
203+
oldProps.className !== newProps.className
204+
);
201205
};
202206
return (props, key) => {
203207
return new Block(root, edits, props, key, shouldUpdate);
@@ -208,30 +212,35 @@ function render(oldCache, newCache) {
208212
return fragment(
209213
list.map((item) => {
210214
const isSelected = selected === item.id;
211-
const cachedItem = oldCache[item.id];
212-
const $key = item.label + String(isSelected);
213-
if (cachedItem?.props.$key === $key) {
214-
return (newCache[item.id] = cachedItem);
215-
}
215+
const id = String(item.id);
216+
// const cachedItem = oldCache[item.id];
217+
// if (cachedItem) {
218+
// if (
219+
// cachedItem.memo[0] === item.label &&
220+
// cachedItem.memo[1] === isSelected
221+
// ) {
222+
// return (newCache[item.id] = cachedItem);
223+
// }
224+
// }
216225

217226
const row = Row(
218227
{
219228
id: item.id,
220229
label: item.label,
221230
className: isSelected ? 'danger' : '',
222-
remove: () => {
231+
remove: withKey(() => {
223232
remove(item.id);
224233
return false;
225-
},
226-
select: () => {
234+
}, id),
235+
select: withKey(() => {
227236
select(item.id);
228237
return false;
229-
},
230-
$key,
238+
}, id),
231239
},
232-
String(item.id)
240+
id
233241
);
234-
newCache[item.id] = row;
242+
row.memo = [item.label, isSelected];
243+
// newCache[item.id] = row;
235244
return row;
236245
})
237246
);
@@ -246,7 +255,7 @@ new Block(
246255
path: [0, 0, 1, 0, 0, 0],
247256
edits: [
248257
{
249-
type: 3,
258+
type: 'event',
250259
name: 'onClick',
251260
listener: create1k,
252261
},
@@ -257,7 +266,7 @@ new Block(
257266
path: [0, 0, 1, 0, 1, 0],
258267
edits: [
259268
{
260-
type: 3,
269+
type: 'event',
261270
name: 'onClick',
262271
listener: create10k,
263272
},
@@ -268,7 +277,7 @@ new Block(
268277
path: [0, 0, 1, 0, 2, 0],
269278
edits: [
270279
{
271-
type: 3,
280+
type: 'event',
272281
name: 'onClick',
273282
listener: append1k,
274283
},
@@ -279,7 +288,7 @@ new Block(
279288
path: [0, 0, 1, 0, 3, 0],
280289
edits: [
281290
{
282-
type: 3,
291+
type: 'event',
283292
name: 'onClick',
284293
listener: updateEvery10,
285294
},
@@ -290,7 +299,7 @@ new Block(
290299
path: [0, 0, 1, 0, 4, 0],
291300
edits: [
292301
{
293-
type: 3,
302+
type: 'event',
294303
name: 'onClick',
295304
listener: () => {
296305
clear();
@@ -305,7 +314,7 @@ new Block(
305314
path: [0, 0, 1, 0, 5, 0],
306315
edits: [
307316
{
308-
type: 3,
317+
type: 'event',
309318
name: 'onClick',
310319
listener: swapRows,
311320
},
@@ -316,7 +325,7 @@ new Block(
316325
path: [1, 0],
317326
edits: [
318327
{
319-
type: 2,
328+
type: 'child',
320329
hole: 'rows',
321330
index: 0,
322331
},

webdriver-ts-results/src/results.ts

Lines changed: 74 additions & 29 deletions
Large diffs are not rendered by default.

webdriver-ts-results/table.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)