fix(record-range): fixes bug when disabling empty ranges.
This commit is contained in:
parent
c59cc8631a
commit
5bdefee6c9
|
@ -188,8 +188,11 @@ export class RecordRange {
|
||||||
var firstEnabledChildRecord = this.findFirstEnabledRecord();
|
var firstEnabledChildRecord = this.findFirstEnabledRecord();
|
||||||
var lastEnabledChildRecord = this.findLastEnabledRecord();
|
var lastEnabledChildRecord = this.findLastEnabledRecord();
|
||||||
|
|
||||||
var nextEnabled = lastEnabledChildRecord.nextEnabled;
|
var nextEnabled = isPresent(lastEnabledChildRecord) ?
|
||||||
var prevEnabled = firstEnabledChildRecord.prevEnabled;
|
lastEnabledChildRecord.nextEnabled : null;
|
||||||
|
|
||||||
|
var prevEnabled = isPresent(firstEnabledChildRecord) ?
|
||||||
|
firstEnabledChildRecord.prevEnabled : null;
|
||||||
|
|
||||||
if (isPresent(nextEnabled)) nextEnabled.prevEnabled = prevEnabled;
|
if (isPresent(nextEnabled)) nextEnabled.prevEnabled = prevEnabled;
|
||||||
if (isPresent(prevEnabled)) prevEnabled.nextEnabled = nextEnabled;
|
if (isPresent(prevEnabled)) prevEnabled.nextEnabled = nextEnabled;
|
||||||
|
|
|
@ -107,6 +107,14 @@ export function main() {
|
||||||
expect(enabledRecords(parent, recordNames)).toEqual(['record1', 'record2']);
|
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', () => {
|
it('should handle adding a range into an empty range', () => {
|
||||||
var emptyRange = new RecordRange(null, null);
|
var emptyRange = new RecordRange(null, null);
|
||||||
parent.addRange(emptyRange);
|
parent.addRange(emptyRange);
|
||||||
|
|
Loading…
Reference in New Issue