Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/change_detection/dirty_checking_change_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ class _MapChangeRecord<K, V> implements MapChangeRecord<K, V> {
_truncate(lastOldSeqRecord, oldSeqRecord);
return isDirty;
}

void _reset() {
var record = _changesHead;
while (record != null) {
Expand Down Expand Up @@ -577,7 +577,7 @@ class _MapChangeRecord<K, V> implements MapChangeRecord<K, V> {
_removalsTail = record;
}
}

void _removeFromSeq(KeyValueRecord prev, KeyValueRecord record) {
KeyValueRecord next = record._nextKeyValue;
if (prev == null) _mapHead = next; else prev._nextKeyValue = next;
Expand Down Expand Up @@ -678,7 +678,7 @@ class _CollectionChangeRecord<K, V> implements CollectionChangeRecord<K, V> {
}

void forEachMove(void f(MovedItem<K, V> change)) {
ItemRecord record = _changesHead;
ItemRecord record = _movesHead;
while(record != null) {
f(record);
record = record._nextMovedRec;
Expand Down Expand Up @@ -782,7 +782,7 @@ class _CollectionChangeRecord<K, V> implements CollectionChangeRecord<K, V> {
mismatch(ItemRecord record, dynamic item, int index) {
// Guard against bogus String changes
if (record != null && item is String && record.item is String &&
record == item) {
record.item == item) {
// this is false change in strings we need to recover, and pretend it is
// the same. We save the value so that next time identity will pass
return record..item = item;
Expand Down
10 changes: 10 additions & 0 deletions test/change_detection/dirty_checking_change_detector_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ main() => describe('DirtyCheckingChangeDetector', () {
removals: []));
});

it('should test string by value rather than by reference', () {
var list = ['a', 'boo'];
var record = detector.watch(list, null, 'handler');
detector.collectChanges();

list[1] = 'b' + 'oo';

expect(detector.collectChanges()).toEqual(null);
});

it('should remove and add same item', () {
var list = ['a', 'b', 'c'];
var record = detector.watch(list, null, 'handler');
Expand Down