Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
import tabbable from 'tabbable';
const div = document.createElement('div');
const tabbables: Array = tabbable(div, {
includeContainer: true,
});
tabbable(div);
tabbables.map(node => node.nodeName);
const isTabbable: boolean = tabbable.isTabbable(document.createElement('a'));
const isFocusable: boolean = tabbable.isFocusable(
document.createElement('button')
);
const untouchabilityChecker = new (class {
hasDisplayNone() {
return true;
}
isUntouchable() {
return false;
}
})();
const isTabbableWithUntouchabilityChecker: boolean = tabbable.isTabbable(
document.createElement('a'),
untouchabilityChecker
const isTabbable: boolean = tabbable.isTabbable(document.createElement('a'));
const isFocusable: boolean = tabbable.isFocusable(
document.createElement('button')
);
const untouchabilityChecker = new (class {
hasDisplayNone() {
return true;
}
isUntouchable() {
return false;
}
})();
const isTabbableWithUntouchabilityChecker: boolean = tabbable.isTabbable(
document.createElement('a'),
untouchabilityChecker
);
const isFocusableWithUntouchabilityChecker: boolean = tabbable.isFocusable(
document.createElement('button'),
untouchabilityChecker
);
const isFocusable2: boolean = tabbable.isFocusable(
document.createElement('button'),
// $ExpectError
3
);
const isTabbable2: boolean = tabbable.isFocusable(
handleEscapeKey = () => {
this.handleOutsideClick();
if (this.controlRef) {
if (tabbable.isTabbable(this.controlRef)) {
this.controlRef.focus();
} else {
const firstTabbableNode = tabbable(this.controlRef)[0];
firstTabbableNode && firstTabbableNode.focus();
}
}
}