diff --git a/lib/change_detection/watch_group.dart b/lib/change_detection/watch_group.dart index 2be94c1a7..49e3e7360 100644 --- a/lib/change_detection/watch_group.dart +++ b/lib/change_detection/watch_group.dart @@ -871,6 +871,8 @@ class _EvalWatchRecord implements WatchRecord<_Handler> { if (value is String && current is String && value == current) { // it is really the same, recover and save so next time identity is same current = value; + } else if (value is num && value.isNaN && current is num && current.isNaN) { + // we need this for the compiled JavaScript since in JS NaN !== NaN. } else { previousValue = current; currentValue = value; diff --git a/test/change_detection/watch_group_spec.dart b/test/change_detection/watch_group_spec.dart index ba5dcdfbd..9614fac80 100644 --- a/test/change_detection/watch_group_spec.dart +++ b/test/change_detection/watch_group_spec.dart @@ -528,6 +528,27 @@ void main() { expect(logger).toEqual([]); }); + it('should ignore NaN != NaN', () { + watchGrp.watch(new ClosureAST('NaN', () => double.NAN, []), (_, __) => logger('NaN')); + + watchGrp.detectChanges(); + expect(logger).toEqual(['NaN']); + + logger.clear(); + watchGrp.detectChanges(); + expect(logger).toEqual([]); + }) ; + + it('should test string by value', () { + watchGrp.watch(new ClosureAST('String', () => 'value', []), (v, _) => logger(v)); + + watchGrp.detectChanges(); + expect(logger).toEqual(['value']); + + logger.clear(); + watchGrp.detectChanges(); + expect(logger).toEqual([]); + }); it('should eval method', () { var obj = new MyClass(logger);