mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
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:
committed by
Caitlin Potter
parent
d488a89466
commit
531a8de72c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user