avoid calling $scope.$apply twice in the same digest cycle if anything is listening on blur() or focus()

fix-space-nbsp 0.3.3
Dmitri Akatov 11 years ago
parent ccdece14ae
commit ba76a3749d

@ -1,5 +1,5 @@
angular.module('contenteditable', [])
.directive('contenteditable', function() { return {
.directive('contenteditable', ['$timeout', function($timeout) { return {
require: 'ngModel',
link: function($scope, $element, attrs, ngModel) {
var old_render
@ -26,8 +26,10 @@ angular.module('contenteditable', [])
if (html === '') {
// the cursor disappears if the contents is empty
// so we need to refocus
$element.blur()
$element.focus()
$timeout(function(){
$element.blur()
$element.focus()
})
}
})
})
@ -68,5 +70,4 @@ angular.module('contenteditable', [])
})
}
}
}})
}}])

@ -1,6 +1,6 @@
{
"name": "angular-contenteditable",
"version": "0.3.2",
"version": "0.3.3",
"main": "angular-contenteditable.js",
"ignore": [
".*",

@ -1,6 +1,6 @@
{
"name": "angular-contenteditable",
"version": "0.3.2",
"version": "0.3.3",
"description": "angular extensions",
"main": "angular-contenteditable.js",
"directories": {