Skip to content

Commit 6083028

Browse files
committed
Optimise
1 parent 28361cb commit 6083028

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/lrud.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
const focusableSelector = '[tabindex], a, input, button';
1919
const containerSelector = 'nav, section, .lrud-container';
2020
const focusableContainerSelector = '[data-lrud-consider-container-distance]';
21-
const ignoredClass = 'lrud-ignore';
21+
const ignoreSelector = '.lrud-ignore, [disabled], [aria-disabled="true"]';
2222

2323
/**
2424
* Element API .matches() with fallbacks
@@ -75,13 +75,11 @@ const getParentContainer = (elem) => {
7575
const getFocusables = (scope) => {
7676
if (!scope) return [];
7777

78-
const ignoredElements = toArray(scope.querySelectorAll('.' + ignoredClass));
79-
if (scope.className.indexOf(ignoredClass) > -1) ignoredElements.push(scope);
78+
const ignoredElements = toArray(scope.querySelectorAll(ignoreSelector));
79+
if (scope.className.indexOf(ignoreSelector) > -1) ignoredElements.push(scope);
8080

8181
return toArray(scope.querySelectorAll(focusableSelector))
8282
.filter(node => !ignoredElements.some(ignored => ignored == node || ignored.contains(node)))
83-
.filter(node => node.getAttribute('disabled') == null)
84-
.filter(node => !(node.getAttribute('aria-disabled') == 'true'))
8583
.filter(node => parseInt(node.getAttribute('tabindex') || '0', 10) > -1);
8684
};
8785

0 commit comments

Comments
 (0)