-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($observe): check if the attribute is undefined #9720
Conversation
I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let us know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
Hi @mary-poppins! I have just signed the CLA. Cheers. |
@@ -1073,7 +1073,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | |||
|
|||
listeners.push(fn); | |||
$rootScope.$evalAsync(function() { | |||
if (!listeners.$$inter) { | |||
if (!listeners.$$inter && typeof attrs[key] !== 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the name attribute is set, but empty? Does the condition apply?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked it and an empty name does not create a property in the scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using attrs.hasOwnProperty(key)
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I have updated my commit ;)
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
I am a fan of this, lets get this in. @Puigcerber you signed with |
@@ -1331,6 +1331,11 @@ describe('input', function() { | |||
expect(scope.name).toEqual('adam'); | |||
}); | |||
|
|||
it('should not add the property to the scope if name is undefined', function() { | |||
compileInput('<input type="text" ng-model="name" />'); | |||
expect(scope.form['undefined']).toBeUndefined(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we should do though, is spy on the compileInput
to make that work
CLA verified by Max Sills and George Lu |
Hi @caitp! Sorry I didn't answer before but I was in the conference. It feels good to have contributed to the core for first time and I hope it's not the last. Thanks for merging! |
Right on, thanks for the patch =] Hope to see more of that from you in the future! |
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
#ngEurope /cc @rodyhaddad @vojtajina