Skip to content

Commit

Permalink
In IE, the blur method doesn't always cause the element to lose focus…
Browse files Browse the repository at this point in the history
… (for example, if the window is not in focus). Use another method to blur the element that does seem to be reliable in IE.
  • Loading branch information
mbest committed Aug 31, 2015
1 parent e3e4b13 commit 9090502
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/binding/defaultBindings/hasfocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ko.bindingHandlers['hasfocus'] = {
'update': function(element, valueAccessor) {
var value = !!ko.utils.unwrapObservable(valueAccessor()); //force boolean to compare with last value
if (!element[hasfocusUpdatingProperty] && element[hasfocusLastValue] !== value) {
value ? element.focus() : element.blur();
value ? element.focus() : (element.blur(), element.ownerDocument.body.focus());
ko.dependencyDetection.ignore(ko.utils.triggerEvent, null, [element, value ? "focusin" : "focusout"]); // For IE, which doesn't reliably fire "focus" or "blur" events synchronously
}
}
Expand Down

0 comments on commit 9090502

Please sign in to comment.