From 078d657c9fb6825834a32b5cf2b208610933e3d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Dec 2013 15:36:49 -0700 Subject: [PATCH] fix(ngBlur): use "safe" $apply while handling events such as blur When the DOM is modified during a digest cycle it can cause the blur event to be raised. Change the code to call $apply only if necessary. Should resolve #5401 --- src/ng/directive/ngEventDirs.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ng/directive/ngEventDirs.js b/src/ng/directive/ngEventDirs.js index a76102c078a8..0e08bcc209c7 100644 --- a/src/ng/directive/ngEventDirs.js +++ b/src/ng/directive/ngEventDirs.js @@ -46,9 +46,13 @@ forEach( var fn = $parse(attr[directiveName]); return function(scope, element, attr) { element.on(lowercase(name), function(event) { - scope.$apply(function() { + if(!scope.$$phase) { + scope.$apply(function() { + fn(scope, {$event:event}); + }); + } else { fn(scope, {$event:event}); - }); + } }); }; }