mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-05 12:16:53 +02:00
Fix object diffing when objects have different keys
The object diff optimisation in 32cca0534c5ff7c7a86d854e6a00a4764652d20b is not correct for the case where `b` has some keys that are not in `a`. By ensuring their key arrays are same length, we can preserve optimisation and be correct as well. Fixes https://github.com/vector-im/element-web/issues/16514
This commit is contained in:
parent
9a56a2efa5
commit
4e87fdcdfe
@ -89,6 +89,7 @@ export function objectHasDiff<O extends {}>(a: O, b: O): boolean {
|
||||
if (a === b) return false;
|
||||
const aKeys = Object.keys(a);
|
||||
const bKeys = Object.keys(b);
|
||||
if (aKeys.length !== bKeys.length) return true;
|
||||
const possibleChanges = arrayUnion(aKeys, bKeys);
|
||||
// if the amalgamation of both sets of keys has the a different length to the inputs then there must be a change
|
||||
if (possibleChanges.length !== aKeys.length) return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user