fix($observe): check if the attribute is undefined

Check if the attribute is undefined before manually applying the function because if not an
undefined property is added to the scope of the form controller when the input control does not
have a name.

Closes #9707
Closes #9720
This commit is contained in:
Pablo Villoslada Puigcerber
2014-10-21 13:57:48 +02:00
committed by Caitlin Potter
parent d488a89466
commit 531a8de72c
2 changed files with 19 additions and 1 deletions

View File

@@ -1331,6 +1331,24 @@ describe('input', function() {
expect(scope.name).toEqual('adam');
});
it('should not add the property to the scope if name is unspecified', function() {
inputElm = jqLite('<input type="text" ng-model="name">');
formElm = jqLite('<form name="form"></form>');
formElm.append(inputElm);
$compile(formElm)(scope);
spyOn(scope.form, '$addControl').andCallThrough();
spyOn(scope.form, '$$renameControl').andCallThrough();
scope.$digest();
expect(scope.form['undefined']).toBeUndefined();
expect(scope.form.$addControl).not.toHaveBeenCalled();
expect(scope.form.$$renameControl).not.toHaveBeenCalled();
});
describe('compositionevents', function() {
it('should not update the model between "compositionstart" and "compositionend" on non android', inject(function($sniffer) {
$sniffer.android = false;