Skip to content

Commit eacedbb

Browse files
Add workaround for tear-offf function equality
dart-lang/sdk#31665 (comment)
1 parent 7d356bc commit eacedbb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/src/util/equality.dart

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:over_react/over_react.dart';
2+
13
/// Returns whether maps [a] and [b] have [identical] sets of values for the same keys.
24
//
35
// Ported from https://github.com/reduxjs/react-redux/blob/573db0bfc8d1d50fdb6e2a98bd8a7d4675fecf11/src/utils/shallowEqual.js
@@ -29,7 +31,16 @@ bool areMapsShallowIdentical(Map a, Map b) {
2931
if (a.length != b.length) return false;
3032
for (final key in a.keys) {
3133
if (!b.containsKey(key)) return false;
32-
if (!identical(b[key], a[key])) return false;
34+
final bVal = b[key];
35+
final aVal = a[key];
36+
// Functions tear-offs are not canonicalized so we have to do a simple
37+
// equality check on them instead of checking identity.
38+
// See: <https://github.com/dart-lang/sdk/issues/31665#issuecomment-352678783>
39+
if (bVal is Function && aVal is Function) {
40+
if (bVal != aVal) return false;
41+
} else {
42+
if (!identical(bVal, aVal)) return false;
43+
}
3344
}
3445
return true;
3546
}

0 commit comments

Comments
 (0)