From 9f6aca4967e5064320e0963f4a2dc6ba196f57da Mon Sep 17 00:00:00 2001 From: James deBoer Date: Wed, 5 Feb 2014 12:44:37 -0800 Subject: [PATCH] fix(eval access): Do not crash on null cached value Fixes #424 --- lib/core/parser/eval_access.dart | 2 +- test/directive/ng_model_spec.dart | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/core/parser/eval_access.dart b/lib/core/parser/eval_access.dart index 59d32b4bf..1e1f53a68 100644 --- a/lib/core/parser/eval_access.dart +++ b/lib/core/parser/eval_access.dart @@ -70,7 +70,7 @@ abstract class AccessReflective { int cachedKind = _cachedKind; if (cachedKind == CACHED_MAP) return holder[name]; var value = _cachedValue; - return (cachedKind == CACHED_FIELD) + return (cachedKind == CACHED_FIELD && value != null) ? value.getField(symbol).reflectee : value; } diff --git a/test/directive/ng_model_spec.dart b/test/directive/ng_model_spec.dart index 09835f225..fbf1b455c 100644 --- a/test/directive/ng_model_spec.dart +++ b/test/directive/ng_model_spec.dart @@ -7,6 +7,11 @@ main() => describe('ng-model', () { TestBed _; + beforeEach(module((Module module) { + module + ..type(ControllerWithNoLove); + })); + beforeEach(inject((TestBed tb) => _ = tb)); describe('type="text" like', () { @@ -600,4 +605,25 @@ describe('ng-model', () { })); }); + describe('error messages', () { + iit('should produce a useful error for bad ng-model expressions', () { + expect(async(() { + _.compile('