Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(eval access): Do not crash on null cached value
Browse files Browse the repository at this point in the history
Fixes #424
  • Loading branch information
jbdeboer committed Feb 5, 2014
1 parent 1ab385e commit bbcbd3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core/parser/eval_access.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
26 changes: 26 additions & 0 deletions test/directive/ng_model_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand Down Expand Up @@ -600,4 +605,25 @@ describe('ng-model', () {
}));
});

describe('error messages', () {
it('should produce a useful error for bad ng-model expressions', () {
expect(async(() {
_.compile('<div no-love><textarea ng-model=ctrl.love probe="loveProbe"></textarea></div');
Probe probe = _.rootScope['loveProbe'];
TextAreaElement inputElement = probe.element;

inputElement.value = 'xzy';
_.triggerEvent(inputElement, 'change');
_.rootScope.$digest();
})).toThrow('love');

});
});
});

@NgController(
selector: '[no-love]',
publishAs: 'ctrl')
class ControllerWithNoLove {
var apathy = null;
}

0 comments on commit bbcbd3e

Please sign in to comment.