diff --git a/lib/change_detection/dirty_checking_change_detector.dart b/lib/change_detection/dirty_checking_change_detector.dart index 6f67b6154..1b431c9bb 100644 --- a/lib/change_detection/dirty_checking_change_detector.dart +++ b/lib/change_detection/dirty_checking_change_detector.dart @@ -488,7 +488,7 @@ class _MapChangeRecord implements MapChangeRecord { _truncate(lastOldSeqRecord, oldSeqRecord); return isDirty; } - + void _reset() { var record = _changesHead; while (record != null) { @@ -577,7 +577,7 @@ class _MapChangeRecord implements MapChangeRecord { _removalsTail = record; } } - + void _removeFromSeq(KeyValueRecord prev, KeyValueRecord record) { KeyValueRecord next = record._nextKeyValue; if (prev == null) _mapHead = next; else prev._nextKeyValue = next; @@ -678,7 +678,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { } void forEachMove(void f(MovedItem change)) { - ItemRecord record = _changesHead; + ItemRecord record = _movesHead; while(record != null) { f(record); record = record._nextMovedRec; @@ -782,7 +782,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { 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; diff --git a/test/change_detection/dirty_checking_change_detector_spec.dart b/test/change_detection/dirty_checking_change_detector_spec.dart index d6da96cac..72a398a46 100644 --- a/test/change_detection/dirty_checking_change_detector_spec.dart +++ b/test/change_detection/dirty_checking_change_detector_spec.dart @@ -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');