Skip to content

Commit

Permalink
Merge branch '703-ie9-frame-hasfocus' of https://github.com/paglias/k…
Browse files Browse the repository at this point in the history
…nockout into paglias-703-ie9-frame-hasfocus
  • Loading branch information
SteveSanderson committed Mar 19, 2013
2 parents bb46e03 + 7bb21ef commit 67087c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/binding/defaultBindings/hasfocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ ko.bindingHandlers['hasfocus'] = {
element[hasfocusUpdatingProperty] = true;
var ownerDoc = element.ownerDocument;
if ("activeElement" in ownerDoc) {
isFocused = (ownerDoc.activeElement === element);
var active;
try {
active = document.activeElement;
} catch(e) {
active = document.body;
}
isFocused = (active === element);
}
var modelValue = valueAccessor();
ko.expressionRewriting.writeValueToProperty(modelValue, allBindingsAccessor, 'hasfocus', isFocused, true);
Expand Down

0 comments on commit 67087c9

Please sign in to comment.