aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive/input.js
diff options
context:
space:
mode:
authorMichał Gołębiowski2013-12-05 14:59:13 +0100
committerIgor Minar2013-12-30 15:09:49 -0800
commit1147f21999edf9a434cd8d24865a6455e744d858 (patch)
tree259a8f54f69f1d3273b598ff912ca22ca8d5a334 /src/ng/directive/input.js
parentbddd46c8ecf49cfe6c999cd6b4a69b7d7e1f9a33 (diff)
downloadangular.js-1147f21999edf9a434cd8d24865a6455e744d858.tar.bz2
fix(input): prevent double $digest when using jQuery trigger.
If an event was performed natively, jQuery sets the isTrigger property. When triggering event manually, the field is not present. Manually triggered events are performed synchronously which causes the "$digest already in progress" error. Closes #5293
Diffstat (limited to 'src/ng/directive/input.js')
-rw-r--r--src/ng/directive/input.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 6a974d9d..c280b7c2 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -407,7 +407,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
});
}
- var listener = function() {
+ var listener = function(ev) {
if (composing) return;
var value = element.val();
@@ -419,9 +419,17 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
}
if (ctrl.$viewValue !== value) {
- scope.$apply(function() {
+ // If an event was performed natively, jQuery sets the isTrigger property.
+ // When triggering event manually, the field is not present. Manually
+ // triggered events are performed synchronously which causes the "$digest
+ // already in progress" error.
+ if (ev && ev.isTrigger) {
ctrl.$setViewValue(value);
- });
+ } else {
+ scope.$apply(function() {
+ ctrl.$setViewValue(value);
+ });
+ }
}
};