Skip to content
Browse files

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
  • Loading branch information...
Puigcerber authored and caitp committed Oct 21, 2014
1 parent d488a89 commit 531a8de72c439d8ddd064874bf364c00cedabb11
Showing with 19 additions and 1 deletion.
  1. +1 −1 src/ng/compile.js
  2. +18 −0 test/ng/directive/inputSpec.js
@@ -1072,7 +1072,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {

$rootScope.$evalAsync(function() {
if (!listeners.$$inter) {
if (!listeners.$$inter && attrs.hasOwnProperty(key)) {

This comment has been minimized.

Copy link

dlongley Nov 10, 2014


Note: If anyone was using attrs.$observe() with an optional attribute (and perhaps using it to set a default value), the handler will no longer execute, which may break your app. If you need the handler to execute, I recommend setting a default value ( = || 'foo') prior to calling $observe.

// no one registered attribute interpolation function, so lets call it manually
@@ -1331,6 +1331,24 @@ describe('input', function() {

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>');

spyOn(scope.form, '$addControl').andCallThrough();
spyOn(scope.form, '$$renameControl').andCallThrough();



describe('compositionevents', function() {
it('should not update the model between "compositionstart" and "compositionend" on non android', inject(function($sniffer) {
$ = false;

0 comments on commit 531a8de

Please sign in to comment.
You can’t perform that action at this time.