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
Show file tree
Hide file tree
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
Expand Up @@ -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]);
}
Expand Down
5 changes: 5 additions & 0 deletions test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 $addControl and $$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;
Expand Down