Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
@@ -1073,7 +1073,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {

listeners.push(fn);
$rootScope.$evalAsync(function() {
if (!listeners.$$inter) {
if (!listeners.$$inter && attrs.hasOwnProperty(key)) {
// no one registered attribute interpolation function, so lets call it manually
fn(attrs[key]);
}
5 changes: 5 additions & 0 deletions test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
@@ -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();
Copy link
Contributor

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 a d d C o n t r o l a n d $renameControl methods of the form though... I think we'd have to rewrite it to not use compileInput to make that work

});

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