summaryrefslogtreecommitdiffstatshomepage
path: root/core/misc/jquery.tabbable.shim.es6.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/misc/jquery.tabbable.shim.es6.js')
-rw-r--r--core/misc/jquery.tabbable.shim.es6.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/misc/jquery.tabbable.shim.es6.js b/core/misc/jquery.tabbable.shim.es6.js
new file mode 100644
index 000000000000..381355f2d665
--- /dev/null
+++ b/core/misc/jquery.tabbable.shim.es6.js
@@ -0,0 +1,23 @@
+/**
+ * @file
+ * Defines a backwards-compatible shim for the jQuery UI :tabbable selector.
+ */
+
+(($, Drupal, { isTabbable }) => {
+ $.extend($.expr[':'], {
+ tabbable(element) {
+ // The tabbable library considers the summary element tabbable, and also
+ // considers a details element without a summary tabbable. The jQuery UI
+ // :tabbable selector does not. This is due to those element types being
+ // inert in IE/Edge.
+ // @see https://allyjs.io/data-tables/focusable.html
+ if (element.tagName === 'SUMMARY' || element.tagName === 'DETAILS') {
+ const tabIndex = element.getAttribute('tabIndex');
+ if (tabIndex === null || tabIndex < 0) {
+ return false;
+ }
+ }
+ return isTabbable(element);
+ },
+ });
+})(jQuery, Drupal, window.tabbable);