Skip to content

Commit

Permalink
Merge pull request reactjs#19 from amccloud/patch-2
Browse files Browse the repository at this point in the history
Check for addEventListener before trying to use to support IE 8
  • Loading branch information
mzabriskie committed Mar 24, 2015
2 parents 10e9582 + c464368 commit bb57045
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/helpers/focusManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,26 @@ exports.returnFocus = function() {

exports.setupScopedFocus = function(element) {
modalElement = element;
window.addEventListener('blur', handleBlur, false);
document.addEventListener('focus', handleFocus, true);

if (window.addEventListener) {
window.addEventListener('blur', handleBlur, false);
document.addEventListener('focus', handleFocus, true);
} else {
window.attachEvent('onBlur', handleBlur);
document.attachEvent('onFocus', handleFocus);
}
};

exports.teardownScopedFocus = function() {
modalElement = null;
window.removeEventListener('blur', handleBlur);
document.removeEventListener('focus', handleFocus);

if (window.addEventListener) {
window.removeEventListener('blur', handleBlur);
document.removeEventListener('focus', handleFocus);
} else {
window.detachEvent('onBlur', handleBlur);
document.detachEvent('onFocus', handleFocus);
}
};


0 comments on commit bb57045

Please sign in to comment.