mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] reactivity: don't react when we set the same object
The purpose of this commit is to not notify reactivity when an object is replaced by the same object (same reference) in an reactive object.
This commit is contained in:
committed by
Sam Degueldre
parent
eec7cc4ea7
commit
6037018dd2
@@ -993,32 +993,33 @@ describe("Reactivity", () => {
|
||||
const obj2 = createReactive({ b: {} }, () => n2++);
|
||||
const obj3 = createReactive({ c: {} }, () => n3++);
|
||||
|
||||
// assign the same object should'nt notify reactivity
|
||||
obj2.b = obj2.b;
|
||||
obj2.b;
|
||||
obj3.c = obj3.c;
|
||||
obj3.c;
|
||||
expect(n1).toBe(0);
|
||||
expect(n2).toBe(1);
|
||||
expect(n3).toBe(1);
|
||||
expect(n2).toBe(0);
|
||||
expect(n3).toBe(0);
|
||||
|
||||
obj2.b = obj1;
|
||||
obj2.b;
|
||||
obj3.c = obj1;
|
||||
obj3.c;
|
||||
expect(n1).toBe(0);
|
||||
expect(n2).toBe(2);
|
||||
expect(n3).toBe(2);
|
||||
expect(n2).toBe(1);
|
||||
expect(n3).toBe(1);
|
||||
|
||||
obj1.a = obj1.a + 2;
|
||||
obj1.a;
|
||||
expect(n1).toBe(1);
|
||||
expect(n2).toBe(2);
|
||||
expect(n3).toBe(2);
|
||||
expect(n2).toBe(1);
|
||||
expect(n3).toBe(1);
|
||||
|
||||
obj2.b.a = obj2.b.a + 1;
|
||||
expect(n1).toBe(2);
|
||||
expect(n2).toBe(3);
|
||||
expect(n3).toBe(2);
|
||||
expect(n2).toBe(2);
|
||||
expect(n3).toBe(1);
|
||||
});
|
||||
|
||||
test("reactive inside other: reading the inner reactive from outer doesn't affect the inner's subscriptions", async () => {
|
||||
|
||||
Reference in New Issue
Block a user