fix(KeyValueDiffer): check for changes

fixes #9115
This commit is contained in:
Victor Berchet
2016-07-15 16:26:54 -07:00
parent 0914dc35e8
commit 3f08efa35d
3 changed files with 48 additions and 11 deletions

View File

@ -79,7 +79,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
throw new BaseException(`Error trying to diff '${map}'`);
}
return this.check(map) ? this : null
return this.check(map) ? this : null;
}
onDestroy() {}
@ -96,11 +96,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
let newSeqRecord: any;
if (oldSeqRecord && key === oldSeqRecord.key) {
newSeqRecord = oldSeqRecord;
if (!looseIdentical(value, oldSeqRecord.currentValue)) {
oldSeqRecord.previousValue = oldSeqRecord.currentValue;
oldSeqRecord.currentValue = value;
this._addToChanges(oldSeqRecord);
}
this._maybeAddToChanges(newSeqRecord, value);
} else {
seqChanged = true;
if (oldSeqRecord !== null) {
@ -109,6 +105,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
}
if (records.has(key)) {
newSeqRecord = records.get(key);
this._maybeAddToChanges(newSeqRecord, value);
} else {
newSeqRecord = new KeyValueChangeRecord(key);
records.set(key, newSeqRecord);
@ -179,6 +176,14 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
}
}
private _maybeAddToChanges(record: KeyValueChangeRecord, newValue: any): void {
if (!looseIdentical(newValue, record.currentValue)) {
record.previousValue = record.currentValue;
record.currentValue = newValue;
this._addToChanges(record);
}
}
/** @internal */
_isInRemovals(record: KeyValueChangeRecord) {
return record === this._removalsHead || record._nextRemoved !== null ||