From 692d2967b50de4df5b11a52337f9f1c6fe6fbca0 Mon Sep 17 00:00:00 2001 From: Lucas Galfaso Date: Sat, 13 Jun 2015 15:45:23 +0200 Subject: [PATCH] fix(input): Firefox validation trigger Do not trigger Firefox validation on form initialization. - Do not set a value to an field if the field already has the same value Closes #12102 --- src/ng/directive/input.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index c3294ed6547c..0dbb03207fe9 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -1125,7 +1125,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); + } }; }