x4js 2.2.57 → 2.2.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "2.2.57",
3
+ "version": "2.2.58",
4
4
  "type": "module",
5
5
  "main": "src/x4.ts",
6
6
  "module": "src/x4.ts",
@@ -982,18 +982,31 @@ export function setWaitCursor(wait: boolean) {
982
982
  * return the focusable elements from a given node
983
983
  */
984
984
 
985
- export function getFocusableElements(root: Element) {
986
- const els = [
987
- 'button:not([tabindex="-1"]):not([disabled])',
985
+ const FOCUSABLE = [
986
+ 'button:not([tabindex="-1"])',
988
987
  '[href]',
989
- 'input:not([disabled])',
990
- 'select:not([disabled])',
991
- 'textarea:not([disabled])',
988
+ 'input',
989
+ 'select',
990
+ 'textarea',
992
991
  '[tabindex]:not([tabindex="-1"])'
993
- ]
992
+ ] .map( x => x+':not(:disabled):not([inert])' )
993
+ .join( ',' );
994
+
995
+ export function getFocusableElements(root: Element) {
996
+ const focusable = Array.from(root.querySelectorAll(FOCUSABLE));
994
997
 
995
- const focusable = Array.from(root.querySelectorAll(els.join(',')));
996
- return focusable.filter(x => (x as HTMLElement).offsetParent != null); // check visibility
998
+ return focusable.filter( x => {
999
+ // check visibility
1000
+ if( (x as HTMLElement).offsetParent == null ) {
1001
+ return false;
1002
+ }
1003
+ // check :inert | :disable
1004
+ if( x.closest('[inert]') || x.closest(":disabled") ) {
1005
+ return false;
1006
+ }
1007
+
1008
+ return true;
1009
+ });
997
1010
  }
998
1011
 
999
1012
  /**