diff --git a/modules/change_detection/src/record_range.js b/modules/change_detection/src/record_range.js index d686c7b993..cd882fa445 100644 --- a/modules/change_detection/src/record_range.js +++ b/modules/change_detection/src/record_range.js @@ -188,8 +188,11 @@ export class RecordRange { var firstEnabledChildRecord = this.findFirstEnabledRecord(); var lastEnabledChildRecord = this.findLastEnabledRecord(); - var nextEnabled = lastEnabledChildRecord.nextEnabled; - var prevEnabled = firstEnabledChildRecord.prevEnabled; + var nextEnabled = isPresent(lastEnabledChildRecord) ? + lastEnabledChildRecord.nextEnabled : null; + + var prevEnabled = isPresent(firstEnabledChildRecord) ? + firstEnabledChildRecord.prevEnabled : null; if (isPresent(nextEnabled)) nextEnabled.prevEnabled = prevEnabled; if (isPresent(prevEnabled)) prevEnabled.nextEnabled = nextEnabled; diff --git a/modules/change_detection/test/record_range_spec.js b/modules/change_detection/test/record_range_spec.js index 446cef8a1a..82312d0c58 100644 --- a/modules/change_detection/test/record_range_spec.js +++ b/modules/change_detection/test/record_range_spec.js @@ -107,6 +107,14 @@ export function main() { expect(enabledRecords(parent, recordNames)).toEqual(['record1', 'record2']); }); + it('should handle enabling/disabling an empty range', () => { + var emptyRange = new RecordRange(null, null); + emptyRange.disable(); + emptyRange.enable(); + + expect(enabledRecords(emptyRange, recordNames)).toEqual([]); + }); + it('should handle adding a range into an empty range', () => { var emptyRange = new RecordRange(null, null); parent.addRange(emptyRange);