diff --git a/modules/entity/spec/unsorted_state_adapter.spec.ts b/modules/entity/spec/unsorted_state_adapter.spec.ts index 0d94a28b2b..40f216e007 100644 --- a/modules/entity/spec/unsorted_state_adapter.spec.ts +++ b/modules/entity/spec/unsorted_state_adapter.spec.ts @@ -11,6 +11,20 @@ describe('Unsorted State Adapter', () => { let adapter: EntityStateAdapter; let state: EntityState; + beforeAll(() => { + Object.defineProperty(Array.prototype, 'unwantedField', { + enumerable: true, + configurable: true, + value: 'This should not appear anywhere', + }); + }); + + afterAll(() => { + Object.defineProperty(Array.prototype, 'unwantedField', { + value: undefined, + }); + }); + beforeEach(() => { adapter = createEntityAdapter({ selectId: (book: BookModel) => book.id, diff --git a/modules/entity/src/unsorted_state_adapter.ts b/modules/entity/src/unsorted_state_adapter.ts index dcf1d53214..72f12585b3 100644 --- a/modules/entity/src/unsorted_state_adapter.ts +++ b/modules/entity/src/unsorted_state_adapter.ts @@ -25,9 +25,8 @@ export function createUnsortedStateAdapter(selectId: IdSelector): any { function addManyMutably(entities: any[], state: any): DidMutate { let didMutate = false; - for (let index in entities) { - didMutate = - addOneMutably(entities[index], state) !== DidMutate.None || didMutate; + for (const entity of entities) { + didMutate = addOneMutably(entity, state) !== DidMutate.None || didMutate; } return didMutate ? DidMutate.Both : DidMutate.None;