focus-lock
Version:
DOM trap for a focus
13 lines (12 loc) • 363 B
JavaScript
export const focusOn = (target, focusOptions) => {
if (!target) {
// not clear how, but is possible https://github.com/theKashey/focus-lock/issues/53
return;
}
if ('focus' in target) {
target.focus(focusOptions);
}
if ('contentWindow' in target && target.contentWindow) {
target.contentWindow.focus();
}
};