Skip to content

Commit

Permalink
Fix bad checking and native function call (#2)
Browse files Browse the repository at this point in the history
As sugested in #1
  • Loading branch information
calvellido committed May 30, 2019
1 parent cc11aeb commit 5aa92d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
@@ -1,7 +1,7 @@
// focus - focusOptions - preventScroll polyfill
var supportsPreventScrollOption = false;
try {
var focusElem = createElement('div');
var focusElem = document.createElement('div');
focusElem.addEventListener('focus', function(event) {
event.preventDefault();
event.stopPropagation();
Expand All @@ -21,7 +21,7 @@ if (HTMLElement.prototype.nativeFocus === undefined && !supportsPreventScrollOpt
var patchedFocus = function (args) {
var actualPosition = window.scrollY;
this.nativeFocus();
if (args.preventScroll) {
if (args && args.preventScroll) {
// Hijacking the event loop order, since the focus() will trigger
// internally an scroll that goes to the event loop
setTimeout(function() {
Expand Down

0 comments on commit 5aa92d8

Please sign in to comment.