Use toggleListener in trapFocus

This commit is contained in:
Albin Larsson 2018-06-12 19:39:26 +02:00
parent f15c1344b0
commit 53933dff7e

View File

@ -2,7 +2,7 @@
// Element utils // Element utils
// ========================================================================== // ==========================================================================
import { off, on } from './events'; import { toggleListener } from './events';
import is from './is'; import is from './is';
// Wrap an element // Wrap an element
@ -277,11 +277,7 @@ export function trapFocus(element = null, toggle = false) {
} }
}; };
if (toggle) { toggleListener.call(this, this.elements.container, 'keydown', trap, toggle, false);
on(this.elements.container, 'keydown', trap, false);
} else {
off(this.elements.container, 'keydown', trap, false);
}
} }
// Toggle aria-pressed state on a toggle button // Toggle aria-pressed state on a toggle button