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

Commit

Permalink
fix(input): Firefox validation trigger
Browse files Browse the repository at this point in the history
Do not trigger Firefox validation on form initialization.
- Do not set a value to an <input> field if the field already has the same value

Closes #12102
  • Loading branch information
lgalfaso committed Jul 26, 2015
1 parent 4bcf6c1 commit e742316
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ng/directive/input.js
Expand Up @@ -1128,7 +1128,11 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
element.on('change', listener);

ctrl.$render = function() {
element.val(ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue);
// Workaround for Firefox validation #12102.
var value = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
if (element.val() !== value) {
element.val(value);
}
};
}

Expand Down

4 comments on commit e742316

@Narretz
Copy link
Contributor

@Narretz Narretz commented on e742316 Aug 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we cannot write a unit test for this?

@Narretz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just ran over this while generating the changelog. @lgalfaso is this okay without a test? It just looks a bit suspicuous

@lgalfaso
Copy link
Contributor Author

@lgalfaso lgalfaso commented on e742316 Aug 13, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgalfaso
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #12592 as a test for this

Please sign in to comment.