@@ -268,7 +268,9 @@ export function hasProperty(obj: object | null, property: string): boolean {
268
268
// SENTINEL constants are from https://github.com/facebook/immutable-js
269
269
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'
270
270
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'
271
+ const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'
271
272
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'
273
+ const IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'
272
274
273
275
export function isImmutableUnorderedKeyed ( maybeKeyed : any ) {
274
276
return ! ! (
@@ -286,6 +288,36 @@ export function isImmutableUnorderedSet(maybeSet: any) {
286
288
)
287
289
}
288
290
291
+ function isObjectLiteral ( source : unknown ) : source is Record < string , unknown > {
292
+ return source != null && typeof source === 'object' && ! Array . isArray ( source )
293
+ }
294
+
295
+ function isImmutableList ( source : unknown ) : boolean {
296
+ return Boolean ( source && isObjectLiteral ( source ) && source [ IS_LIST_SENTINEL ] )
297
+ }
298
+
299
+ function isImmutableOrderedKeyed ( source : unknown ) : boolean {
300
+ return Boolean (
301
+ source
302
+ && isObjectLiteral ( source )
303
+ && source [ IS_KEYED_SENTINEL ]
304
+ && source [ IS_ORDERED_SENTINEL ] ,
305
+ )
306
+ }
307
+
308
+ function isImmutableOrderedSet ( source : unknown ) : boolean {
309
+ return Boolean (
310
+ source
311
+ && isObjectLiteral ( source )
312
+ && source [ IS_SET_SENTINEL ]
313
+ && source [ IS_ORDERED_SENTINEL ] ,
314
+ )
315
+ }
316
+
317
+ function isImmutableRecord ( source : unknown ) : boolean {
318
+ return Boolean ( source && isObjectLiteral ( source ) && source [ IS_RECORD_SYMBOL ] )
319
+ }
320
+
289
321
/**
290
322
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
291
323
*
@@ -411,10 +443,17 @@ export function iterableEquality(a: any, b: any, customTesters: Array<Tester> =
411
443
if ( ! bIterator . next ( ) . done )
412
444
return false
413
445
414
- const aEntries = Object . entries ( a )
415
- const bEntries = Object . entries ( b )
416
- if ( ! equals ( aEntries , bEntries ) )
417
- return false
446
+ if (
447
+ ! isImmutableList ( a )
448
+ && ! isImmutableOrderedKeyed ( a )
449
+ && ! isImmutableOrderedSet ( a )
450
+ && ! isImmutableRecord ( a )
451
+ ) {
452
+ const aEntries = Object . entries ( a )
453
+ const bEntries = Object . entries ( b )
454
+ if ( ! equals ( aEntries , bEntries ) )
455
+ return false
456
+ }
418
457
419
458
// Remove the first value from the stack of traversed values.
420
459
aStack . pop ( )
0 commit comments