Skip to content

Instantly share code, notes, and snippets.

View Cryrivers's full-sized avatar
🎩
Making every second count

Zhongliang Wang Cryrivers

🎩
Making every second count
View GitHub Profile
function isVisible(element) {
const style = window.getComputedStyle(element);
return style.display !== 'none';
}
function isFocusable (element) {
const focusableElements = [
'a[href]',
'button:enabled',
'input:enabled',
function setFocusIfFocusable(node) {
if (node.nodeType !== Node.ELEMENT_NODE) {
// Text and comment nodes aren't focusable.
return false;
}
if (node.disabled === true) {
// Disabled elements can't be focused.
return false;
}