Skip to content

Commit 1c00869

Browse files
committed
Fix traversal list ordering
1 parent b6ba643 commit 1c00869

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

one-way-data-binding-library.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ export default (bindings) => {
1212

1313
scan(Object.keys(bindings), {
1414
joined: true,
15+
reverse: false,
1516
rtn: ["key", "value", "matchedBy"],
1617
})(state).forEach(([key, data, matchedBy]) => {
18+
console.log(key);
1719
matchedBy.forEach((match) => {
1820
// No binding exists for this key; bind and call create method
1921
if (!(key in bound)) {

one-way-data-binding-library.test.mjs

+16
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,20 @@ describe("one-way-data-binding-library", () => {
273273

274274
expect(runs).toBe(1);
275275
});
276+
277+
it("runs creates in list order", () => {
278+
let order = [];
279+
280+
const foo = () => ({
281+
create: (data) => order.push(data),
282+
});
283+
284+
const run = bind({
285+
"state.foo[*]": foo,
286+
});
287+
288+
run(() => ({ state: { foo: [1, 2, 3] } }));
289+
290+
expect(order).toEqual([1, 2, 3]);
291+
});
276292
});

0 commit comments

Comments
 (0)