Comparing version 6.1.2 to 6.2.0
# Changelog | ||
## 6.2.0 | ||
### Minor Changes | ||
- 18a093f: Add new `getTabIndex()` API which enables Focus-trap to determine tab indexes in the same way as Tabbable when necessary (see [focus-trap#974](https://github.com/focus-trap/focus-trap/pull/974)). | ||
## 6.1.2 | ||
@@ -4,0 +10,0 @@ |
/*! | ||
* tabbable 6.1.2 | ||
* tabbable 6.2.0 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
@@ -182,3 +182,23 @@ */ | ||
}; | ||
var getTabindex = function getTabindex(node, isScope) { | ||
/** | ||
* @private | ||
* Determines if the node has an explicitly specified `tabindex` attribute. | ||
* @param {HTMLElement} node | ||
* @returns {boolean} True if so; false if not. | ||
*/ | ||
var hasTabIndex = function hasTabIndex(node) { | ||
return !isNaN(parseInt(node.getAttribute('tabindex'), 10)); | ||
}; | ||
/** | ||
* Determine the tab index of a given node. | ||
* @param {HTMLElement} node | ||
* @returns {number} Tab order (negative, 0, or positive number). | ||
* @throws {Error} If `node` is falsy. | ||
*/ | ||
var getTabIndex = function getTabIndex(node) { | ||
if (!node) { | ||
throw new Error('No node provided'); | ||
} | ||
if (node.tabIndex < 0) { | ||
@@ -192,7 +212,3 @@ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default | ||
// so if they don't have a tabindex attribute specifically set, assume it's 0. | ||
// | ||
// isScope is positive for custom element with shadow root or slot that by default | ||
// have tabIndex -1, but need to be sorted by document order in order for their | ||
// content to be inserted in the correct position | ||
if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) { | ||
if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) { | ||
return 0; | ||
@@ -203,2 +219,18 @@ } | ||
}; | ||
/** | ||
* Determine the tab index of a given node __for sort order purposes__. | ||
* @param {HTMLElement} node | ||
* @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default, | ||
* has tabIndex -1, but needs to be sorted by document order in order for its content to be | ||
* inserted into the correct sort position. | ||
* @returns {number} Tab order (negative, 0, or positive number). | ||
*/ | ||
var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) { | ||
var tabIndex = getTabIndex(node); | ||
if (tabIndex < 0 && isScope && !hasTabIndex(node)) { | ||
return 0; | ||
} | ||
return tabIndex; | ||
}; | ||
var sortOrderedTabbables = function sortOrderedTabbables(a, b) { | ||
@@ -446,3 +478,3 @@ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex; | ||
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) { | ||
if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { | ||
if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { | ||
return false; | ||
@@ -472,3 +504,3 @@ } | ||
var element = isScope ? item.scopeParent : item; | ||
var candidateTabindex = getTabindex(element, isScope); | ||
var candidateTabindex = getSortOrderTabIndex(element, isScope); | ||
var elements = isScope ? sortByOrder(item.candidates) : element; | ||
@@ -492,7 +524,7 @@ if (candidateTabindex === 0) { | ||
}; | ||
var tabbable = function tabbable(el, options) { | ||
var tabbable = function tabbable(container, options) { | ||
options = options || {}; | ||
var candidates; | ||
if (options.getShadowRoot) { | ||
candidates = getCandidatesIteratively([el], options.includeContainer, { | ||
candidates = getCandidatesIteratively([container], options.includeContainer, { | ||
filter: isNodeMatchingSelectorTabbable.bind(null, options), | ||
@@ -504,11 +536,11 @@ flatten: false, | ||
} else { | ||
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); | ||
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); | ||
} | ||
return sortByOrder(candidates); | ||
}; | ||
var focusable = function focusable(el, options) { | ||
var focusable = function focusable(container, options) { | ||
options = options || {}; | ||
var candidates; | ||
if (options.getShadowRoot) { | ||
candidates = getCandidatesIteratively([el], options.includeContainer, { | ||
candidates = getCandidatesIteratively([container], options.includeContainer, { | ||
filter: isNodeMatchingSelectorFocusable.bind(null, options), | ||
@@ -519,3 +551,3 @@ flatten: true, | ||
} else { | ||
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options)); | ||
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options)); | ||
} | ||
@@ -546,3 +578,3 @@ return candidates; | ||
export { focusable, isFocusable, isTabbable, tabbable }; | ||
export { focusable, getTabIndex, isFocusable, isTabbable, tabbable }; | ||
//# sourceMappingURL=index.esm.js.map |
/*! | ||
* tabbable 6.1.2 | ||
* tabbable 6.2.0 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
*/ | ||
var t=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],e=t.join(","),n="undefined"==typeof Element,o=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,r=!n&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},i=function t(e,n){var o;void 0===n&&(n=!0);var r=null==e||null===(o=e.getAttribute)||void 0===o?void 0:o.call(e,"inert");return""===r||"true"===r||n&&e&&t(e.parentNode)},a=function(t,n,r){if(i(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(e));return n&&o.call(t,e)&&a.unshift(t),a=a.filter(r)},l=function t(n,r,a){for(var l=[],u=Array.from(n);u.length;){var d=u.shift();if(!i(d,!1))if("SLOT"===d.tagName){var c=d.assignedElements(),f=t(c.length?c:d.children,!0,a);a.flatten?l.push.apply(l,f):l.push({scopeParent:d,candidates:f})}else{o.call(d,e)&&a.filter(d)&&(r||!n.includes(d))&&l.push(d);var s=d.shadowRoot||"function"==typeof a.getShadowRoot&&a.getShadowRoot(d),p=!i(s,!1)&&(!a.shadowRootFilter||a.shadowRootFilter(d));if(s&&p){var h=t(!0===s?d.children:s.children,!0,a);a.flatten?l.push.apply(l,h):l.push({scopeParent:d,candidates:h})}else u.unshift.apply(u,d.children)}}return l},u=function(t,e){return t.tabIndex<0&&(e||/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&isNaN(parseInt(t.getAttribute("tabindex"),10))?0:t.tabIndex},d=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},c=function(t){return"INPUT"===t.tagName},f=function(t){return function(t){return c(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||r(t),o=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=o(window.CSS.escape(t.name));else try{e=o(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var i=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!i||i===t}(t)},s=function(t){var e=t.getBoundingClientRect(),n=e.width,o=e.height;return 0===n&&0===o},p=function(t,e){var n=e.displayCheck,i=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var a=o.call(t,"details>summary:first-of-type")?t.parentElement:t;if(o.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return s(t)}else{if("function"==typeof i){for(var l=t;t;){var u=t.parentElement,d=r(t);if(u&&!u.shadowRoot&&!0===i(u))return s(t);t=t.assignedSlot?t.assignedSlot:u||d===t.ownerDocument?u:d.host}t=l}if(function(t){var e,n,o,i,a=t&&r(t),l=null===(e=a)||void 0===e?void 0:e.host,u=!1;if(a&&a!==t)for(u=!!(null!==(n=l)&&void 0!==n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(l)||null!=t&&null!==(i=t.ownerDocument)&&void 0!==i&&i.contains(t));!u&&l;){var d,c,f;u=!(null===(c=l=null===(d=a=r(l))||void 0===d?void 0:d.host)||void 0===c||null===(f=c.ownerDocument)||void 0===f||!f.contains(l))}return u}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},h=function(t,e){return!(e.disabled||i(e)||function(t){return c(t)&&"hidden"===t.type}(e)||p(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var r=e.children.item(n);if("LEGEND"===r.tagName)return!!o.call(e,"fieldset[disabled] *")||!r.contains(t)}return!0}e=e.parentElement}return!1}(e))},v=function(t,e){return!(f(e)||u(e)<0||!h(t,e))},m=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},g=function t(e){var n=[],o=[];return e.forEach((function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,l=u(a,i),d=i?t(e.candidates):a;0===l?i?n.push.apply(n,d):n.push(a):o.push({documentOrder:r,tabIndex:l,item:e,isScope:i,content:d})})),o.sort(d).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},y=function(t,e){var n;return n=(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:v.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:m}):a(t,e.includeContainer,v.bind(null,e)),g(n)},w=function(t,e){return(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:h.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):a(t,e.includeContainer,h.bind(null,e))},S=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return!1!==o.call(t,e)&&v(n,t)},b=t.concat("iframe").join(","),E=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==o.call(t,b)&&h(e,t)};export{w as focusable,E as isFocusable,S as isTabbable,y as tabbable}; | ||
var t=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],e=t.join(","),n="undefined"==typeof Element,o=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,r=!n&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},i=function t(e,n){var o;void 0===n&&(n=!0);var r=null==e||null===(o=e.getAttribute)||void 0===o?void 0:o.call(e,"inert");return""===r||"true"===r||n&&e&&t(e.parentNode)},a=function(t,n,r){if(i(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(e));return n&&o.call(t,e)&&a.unshift(t),a=a.filter(r)},l=function t(n,r,a){for(var l=[],u=Array.from(n);u.length;){var d=u.shift();if(!i(d,!1))if("SLOT"===d.tagName){var c=d.assignedElements(),f=t(c.length?c:d.children,!0,a);a.flatten?l.push.apply(l,f):l.push({scopeParent:d,candidates:f})}else{o.call(d,e)&&a.filter(d)&&(r||!n.includes(d))&&l.push(d);var s=d.shadowRoot||"function"==typeof a.getShadowRoot&&a.getShadowRoot(d),p=!i(s,!1)&&(!a.shadowRootFilter||a.shadowRootFilter(d));if(s&&p){var h=t(!0===s?d.children:s.children,!0,a);a.flatten?l.push.apply(l,h):l.push({scopeParent:d,candidates:h})}else u.unshift.apply(u,d.children)}}return l},u=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},d=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&!u(t)?0:t.tabIndex},c=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},f=function(t){return"INPUT"===t.tagName},s=function(t){return function(t){return f(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||r(t),o=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=o(window.CSS.escape(t.name));else try{e=o(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var i=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!i||i===t}(t)},p=function(t){var e=t.getBoundingClientRect(),n=e.width,o=e.height;return 0===n&&0===o},h=function(t,e){var n=e.displayCheck,i=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var a=o.call(t,"details>summary:first-of-type")?t.parentElement:t;if(o.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return p(t)}else{if("function"==typeof i){for(var l=t;t;){var u=t.parentElement,d=r(t);if(u&&!u.shadowRoot&&!0===i(u))return p(t);t=t.assignedSlot?t.assignedSlot:u||d===t.ownerDocument?u:d.host}t=l}if(function(t){var e,n,o,i,a=t&&r(t),l=null===(e=a)||void 0===e?void 0:e.host,u=!1;if(a&&a!==t)for(u=!!(null!==(n=l)&&void 0!==n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(l)||null!=t&&null!==(i=t.ownerDocument)&&void 0!==i&&i.contains(t));!u&&l;){var d,c,f;u=!(null===(c=l=null===(d=a=r(l))||void 0===d?void 0:d.host)||void 0===c||null===(f=c.ownerDocument)||void 0===f||!f.contains(l))}return u}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},v=function(t,e){return!(e.disabled||i(e)||function(t){return f(t)&&"hidden"===t.type}(e)||h(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var r=e.children.item(n);if("LEGEND"===r.tagName)return!!o.call(e,"fieldset[disabled] *")||!r.contains(t)}return!0}e=e.parentElement}return!1}(e))},m=function(t,e){return!(s(e)||d(e)<0||!v(t,e))},g=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},y=function t(e){var n=[],o=[];return e.forEach((function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,l=function(t,e){var n=d(t);return n<0&&e&&!u(t)?0:n}(a,i),c=i?t(e.candidates):a;0===l?i?n.push.apply(n,c):n.push(a):o.push({documentOrder:r,tabIndex:l,item:e,isScope:i,content:c})})),o.sort(c).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},w=function(t,e){var n;return n=(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:m.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:g}):a(t,e.includeContainer,m.bind(null,e)),y(n)},S=function(t,e){return(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:v.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):a(t,e.includeContainer,v.bind(null,e))},b=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return!1!==o.call(t,e)&&m(n,t)},E=t.concat("iframe").join(","),N=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==o.call(t,E)&&v(e,t)};export{S as focusable,d as getTabIndex,N as isFocusable,b as isTabbable,w as tabbable}; | ||
//# sourceMappingURL=index.esm.min.js.map |
/*! | ||
* tabbable 6.1.2 | ||
* tabbable 6.2.0 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
@@ -186,3 +186,23 @@ */ | ||
}; | ||
var getTabindex = function getTabindex(node, isScope) { | ||
/** | ||
* @private | ||
* Determines if the node has an explicitly specified `tabindex` attribute. | ||
* @param {HTMLElement} node | ||
* @returns {boolean} True if so; false if not. | ||
*/ | ||
var hasTabIndex = function hasTabIndex(node) { | ||
return !isNaN(parseInt(node.getAttribute('tabindex'), 10)); | ||
}; | ||
/** | ||
* Determine the tab index of a given node. | ||
* @param {HTMLElement} node | ||
* @returns {number} Tab order (negative, 0, or positive number). | ||
* @throws {Error} If `node` is falsy. | ||
*/ | ||
var getTabIndex = function getTabIndex(node) { | ||
if (!node) { | ||
throw new Error('No node provided'); | ||
} | ||
if (node.tabIndex < 0) { | ||
@@ -196,7 +216,3 @@ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default | ||
// so if they don't have a tabindex attribute specifically set, assume it's 0. | ||
// | ||
// isScope is positive for custom element with shadow root or slot that by default | ||
// have tabIndex -1, but need to be sorted by document order in order for their | ||
// content to be inserted in the correct position | ||
if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) { | ||
if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) { | ||
return 0; | ||
@@ -207,2 +223,18 @@ } | ||
}; | ||
/** | ||
* Determine the tab index of a given node __for sort order purposes__. | ||
* @param {HTMLElement} node | ||
* @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default, | ||
* has tabIndex -1, but needs to be sorted by document order in order for its content to be | ||
* inserted into the correct sort position. | ||
* @returns {number} Tab order (negative, 0, or positive number). | ||
*/ | ||
var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) { | ||
var tabIndex = getTabIndex(node); | ||
if (tabIndex < 0 && isScope && !hasTabIndex(node)) { | ||
return 0; | ||
} | ||
return tabIndex; | ||
}; | ||
var sortOrderedTabbables = function sortOrderedTabbables(a, b) { | ||
@@ -450,3 +482,3 @@ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex; | ||
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) { | ||
if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { | ||
if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { | ||
return false; | ||
@@ -476,3 +508,3 @@ } | ||
var element = isScope ? item.scopeParent : item; | ||
var candidateTabindex = getTabindex(element, isScope); | ||
var candidateTabindex = getSortOrderTabIndex(element, isScope); | ||
var elements = isScope ? sortByOrder(item.candidates) : element; | ||
@@ -496,7 +528,7 @@ if (candidateTabindex === 0) { | ||
}; | ||
var tabbable = function tabbable(el, options) { | ||
var tabbable = function tabbable(container, options) { | ||
options = options || {}; | ||
var candidates; | ||
if (options.getShadowRoot) { | ||
candidates = getCandidatesIteratively([el], options.includeContainer, { | ||
candidates = getCandidatesIteratively([container], options.includeContainer, { | ||
filter: isNodeMatchingSelectorTabbable.bind(null, options), | ||
@@ -508,11 +540,11 @@ flatten: false, | ||
} else { | ||
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); | ||
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); | ||
} | ||
return sortByOrder(candidates); | ||
}; | ||
var focusable = function focusable(el, options) { | ||
var focusable = function focusable(container, options) { | ||
options = options || {}; | ||
var candidates; | ||
if (options.getShadowRoot) { | ||
candidates = getCandidatesIteratively([el], options.includeContainer, { | ||
candidates = getCandidatesIteratively([container], options.includeContainer, { | ||
filter: isNodeMatchingSelectorFocusable.bind(null, options), | ||
@@ -523,3 +555,3 @@ flatten: true, | ||
} else { | ||
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options)); | ||
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options)); | ||
} | ||
@@ -551,2 +583,3 @@ return candidates; | ||
exports.focusable = focusable; | ||
exports.getTabIndex = getTabIndex; | ||
exports.isFocusable = isFocusable; | ||
@@ -553,0 +586,0 @@ exports.isTabbable = isTabbable; |
/*! | ||
* tabbable 6.1.2 | ||
* tabbable 6.2.0 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],e=t.join(","),n="undefined"==typeof Element,o=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,r=!n&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},i=function t(e,n){var o;void 0===n&&(n=!0);var r=null==e||null===(o=e.getAttribute)||void 0===o?void 0:o.call(e,"inert");return""===r||"true"===r||n&&e&&t(e.parentNode)},a=function(t,n,r){if(i(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(e));return n&&o.call(t,e)&&a.unshift(t),a=a.filter(r)},l=function t(n,r,a){for(var l=[],u=Array.from(n);u.length;){var d=u.shift();if(!i(d,!1))if("SLOT"===d.tagName){var c=d.assignedElements(),s=t(c.length?c:d.children,!0,a);a.flatten?l.push.apply(l,s):l.push({scopeParent:d,candidates:s})}else{o.call(d,e)&&a.filter(d)&&(r||!n.includes(d))&&l.push(d);var f=d.shadowRoot||"function"==typeof a.getShadowRoot&&a.getShadowRoot(d),p=!i(f,!1)&&(!a.shadowRootFilter||a.shadowRootFilter(d));if(f&&p){var h=t(!0===f?d.children:f.children,!0,a);a.flatten?l.push.apply(l,h):l.push({scopeParent:d,candidates:h})}else u.unshift.apply(u,d.children)}}return l},u=function(t,e){return t.tabIndex<0&&(e||/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&isNaN(parseInt(t.getAttribute("tabindex"),10))?0:t.tabIndex},d=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},c=function(t){return"INPUT"===t.tagName},s=function(t){return function(t){return c(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||r(t),o=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=o(window.CSS.escape(t.name));else try{e=o(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var i=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!i||i===t}(t)},f=function(t){var e=t.getBoundingClientRect(),n=e.width,o=e.height;return 0===n&&0===o},p=function(t,e){var n=e.displayCheck,i=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var a=o.call(t,"details>summary:first-of-type")?t.parentElement:t;if(o.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return f(t)}else{if("function"==typeof i){for(var l=t;t;){var u=t.parentElement,d=r(t);if(u&&!u.shadowRoot&&!0===i(u))return f(t);t=t.assignedSlot?t.assignedSlot:u||d===t.ownerDocument?u:d.host}t=l}if(function(t){var e,n,o,i,a=t&&r(t),l=null===(e=a)||void 0===e?void 0:e.host,u=!1;if(a&&a!==t)for(u=!!(null!==(n=l)&&void 0!==n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(l)||null!=t&&null!==(i=t.ownerDocument)&&void 0!==i&&i.contains(t));!u&&l;){var d,c,s;u=!(null===(c=l=null===(d=a=r(l))||void 0===d?void 0:d.host)||void 0===c||null===(s=c.ownerDocument)||void 0===s||!s.contains(l))}return u}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},h=function(t,e){return!(e.disabled||i(e)||function(t){return c(t)&&"hidden"===t.type}(e)||p(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var r=e.children.item(n);if("LEGEND"===r.tagName)return!!o.call(e,"fieldset[disabled] *")||!r.contains(t)}return!0}e=e.parentElement}return!1}(e))},v=function(t,e){return!(s(e)||u(e)<0||!h(t,e))},m=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},g=function t(e){var n=[],o=[];return e.forEach((function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,l=u(a,i),d=i?t(e.candidates):a;0===l?i?n.push.apply(n,d):n.push(a):o.push({documentOrder:r,tabIndex:l,item:e,isScope:i,content:d})})),o.sort(d).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},y=t.concat("iframe").join(",");exports.focusable=function(t,e){return(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:h.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):a(t,e.includeContainer,h.bind(null,e))},exports.isFocusable=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==o.call(t,y)&&h(e,t)},exports.isTabbable=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return!1!==o.call(t,e)&&v(n,t)},exports.tabbable=function(t,e){var n;return n=(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:v.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:m}):a(t,e.includeContainer,v.bind(null,e)),g(n)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],e=t.join(","),n="undefined"==typeof Element,o=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,r=!n&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},i=function t(e,n){var o;void 0===n&&(n=!0);var r=null==e||null===(o=e.getAttribute)||void 0===o?void 0:o.call(e,"inert");return""===r||"true"===r||n&&e&&t(e.parentNode)},a=function(t,n,r){if(i(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(e));return n&&o.call(t,e)&&a.unshift(t),a=a.filter(r)},l=function t(n,r,a){for(var l=[],u=Array.from(n);u.length;){var d=u.shift();if(!i(d,!1))if("SLOT"===d.tagName){var c=d.assignedElements(),s=t(c.length?c:d.children,!0,a);a.flatten?l.push.apply(l,s):l.push({scopeParent:d,candidates:s})}else{o.call(d,e)&&a.filter(d)&&(r||!n.includes(d))&&l.push(d);var f=d.shadowRoot||"function"==typeof a.getShadowRoot&&a.getShadowRoot(d),p=!i(f,!1)&&(!a.shadowRootFilter||a.shadowRootFilter(d));if(f&&p){var h=t(!0===f?d.children:f.children,!0,a);a.flatten?l.push.apply(l,h):l.push({scopeParent:d,candidates:h})}else u.unshift.apply(u,d.children)}}return l},u=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},d=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&!u(t)?0:t.tabIndex},c=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},s=function(t){return"INPUT"===t.tagName},f=function(t){return function(t){return s(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||r(t),o=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=o(window.CSS.escape(t.name));else try{e=o(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var i=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!i||i===t}(t)},p=function(t){var e=t.getBoundingClientRect(),n=e.width,o=e.height;return 0===n&&0===o},h=function(t,e){var n=e.displayCheck,i=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var a=o.call(t,"details>summary:first-of-type")?t.parentElement:t;if(o.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return p(t)}else{if("function"==typeof i){for(var l=t;t;){var u=t.parentElement,d=r(t);if(u&&!u.shadowRoot&&!0===i(u))return p(t);t=t.assignedSlot?t.assignedSlot:u||d===t.ownerDocument?u:d.host}t=l}if(function(t){var e,n,o,i,a=t&&r(t),l=null===(e=a)||void 0===e?void 0:e.host,u=!1;if(a&&a!==t)for(u=!!(null!==(n=l)&&void 0!==n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(l)||null!=t&&null!==(i=t.ownerDocument)&&void 0!==i&&i.contains(t));!u&&l;){var d,c,s;u=!(null===(c=l=null===(d=a=r(l))||void 0===d?void 0:d.host)||void 0===c||null===(s=c.ownerDocument)||void 0===s||!s.contains(l))}return u}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},v=function(t,e){return!(e.disabled||i(e)||function(t){return s(t)&&"hidden"===t.type}(e)||h(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var r=e.children.item(n);if("LEGEND"===r.tagName)return!!o.call(e,"fieldset[disabled] *")||!r.contains(t)}return!0}e=e.parentElement}return!1}(e))},m=function(t,e){return!(f(e)||d(e)<0||!v(t,e))},g=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},b=function t(e){var n=[],o=[];return e.forEach((function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,l=function(t,e){var n=d(t);return n<0&&e&&!u(t)?0:n}(a,i),c=i?t(e.candidates):a;0===l?i?n.push.apply(n,c):n.push(a):o.push({documentOrder:r,tabIndex:l,item:e,isScope:i,content:c})})),o.sort(c).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},y=t.concat("iframe").join(",");exports.focusable=function(t,e){return(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:v.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):a(t,e.includeContainer,v.bind(null,e))},exports.getTabIndex=d,exports.isFocusable=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==o.call(t,y)&&v(e,t)},exports.isTabbable=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return!1!==o.call(t,e)&&m(n,t)},exports.tabbable=function(t,e){var n;return n=(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:m.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:g}):a(t,e.includeContainer,m.bind(null,e)),b(n)}; | ||
//# sourceMappingURL=index.min.js.map |
/*! | ||
* tabbable 6.1.2 | ||
* tabbable 6.2.0 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
@@ -193,3 +193,23 @@ */ | ||
}; | ||
var getTabindex = function getTabindex(node, isScope) { | ||
/** | ||
* @private | ||
* Determines if the node has an explicitly specified `tabindex` attribute. | ||
* @param {HTMLElement} node | ||
* @returns {boolean} True if so; false if not. | ||
*/ | ||
var hasTabIndex = function hasTabIndex(node) { | ||
return !isNaN(parseInt(node.getAttribute('tabindex'), 10)); | ||
}; | ||
/** | ||
* Determine the tab index of a given node. | ||
* @param {HTMLElement} node | ||
* @returns {number} Tab order (negative, 0, or positive number). | ||
* @throws {Error} If `node` is falsy. | ||
*/ | ||
var getTabIndex = function getTabIndex(node) { | ||
if (!node) { | ||
throw new Error('No node provided'); | ||
} | ||
if (node.tabIndex < 0) { | ||
@@ -203,7 +223,3 @@ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default | ||
// so if they don't have a tabindex attribute specifically set, assume it's 0. | ||
// | ||
// isScope is positive for custom element with shadow root or slot that by default | ||
// have tabIndex -1, but need to be sorted by document order in order for their | ||
// content to be inserted in the correct position | ||
if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) { | ||
if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) { | ||
return 0; | ||
@@ -214,2 +230,18 @@ } | ||
}; | ||
/** | ||
* Determine the tab index of a given node __for sort order purposes__. | ||
* @param {HTMLElement} node | ||
* @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default, | ||
* has tabIndex -1, but needs to be sorted by document order in order for its content to be | ||
* inserted into the correct sort position. | ||
* @returns {number} Tab order (negative, 0, or positive number). | ||
*/ | ||
var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) { | ||
var tabIndex = getTabIndex(node); | ||
if (tabIndex < 0 && isScope && !hasTabIndex(node)) { | ||
return 0; | ||
} | ||
return tabIndex; | ||
}; | ||
var sortOrderedTabbables = function sortOrderedTabbables(a, b) { | ||
@@ -457,3 +489,3 @@ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex; | ||
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) { | ||
if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { | ||
if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { | ||
return false; | ||
@@ -483,3 +515,3 @@ } | ||
var element = isScope ? item.scopeParent : item; | ||
var candidateTabindex = getTabindex(element, isScope); | ||
var candidateTabindex = getSortOrderTabIndex(element, isScope); | ||
var elements = isScope ? sortByOrder(item.candidates) : element; | ||
@@ -503,7 +535,7 @@ if (candidateTabindex === 0) { | ||
}; | ||
var tabbable = function tabbable(el, options) { | ||
var tabbable = function tabbable(container, options) { | ||
options = options || {}; | ||
var candidates; | ||
if (options.getShadowRoot) { | ||
candidates = getCandidatesIteratively([el], options.includeContainer, { | ||
candidates = getCandidatesIteratively([container], options.includeContainer, { | ||
filter: isNodeMatchingSelectorTabbable.bind(null, options), | ||
@@ -515,11 +547,11 @@ flatten: false, | ||
} else { | ||
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); | ||
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); | ||
} | ||
return sortByOrder(candidates); | ||
}; | ||
var focusable = function focusable(el, options) { | ||
var focusable = function focusable(container, options) { | ||
options = options || {}; | ||
var candidates; | ||
if (options.getShadowRoot) { | ||
candidates = getCandidatesIteratively([el], options.includeContainer, { | ||
candidates = getCandidatesIteratively([container], options.includeContainer, { | ||
filter: isNodeMatchingSelectorFocusable.bind(null, options), | ||
@@ -530,3 +562,3 @@ flatten: true, | ||
} else { | ||
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options)); | ||
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options)); | ||
} | ||
@@ -558,2 +590,3 @@ return candidates; | ||
exports.focusable = focusable; | ||
exports.getTabIndex = getTabIndex; | ||
exports.isFocusable = isFocusable; | ||
@@ -560,0 +593,0 @@ exports.isTabbable = isTabbable; |
/*! | ||
* tabbable 6.1.2 | ||
* tabbable 6.2.0 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):(t="undefined"!=typeof globalThis?globalThis:t||self,function(){var n=t.tabbable,o=t.tabbable={};e(o),o.noConflict=function(){return t.tabbable=n,o}}())}(this,(function(t){"use strict";var e=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],n=e.join(","),o="undefined"==typeof Element,r=o?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,i=!o&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},a=function t(e,n){var o;void 0===n&&(n=!0);var r=null==e||null===(o=e.getAttribute)||void 0===o?void 0:o.call(e,"inert");return""===r||"true"===r||n&&e&&t(e.parentNode)},l=function(t,e,o){if(a(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(n));return e&&r.call(t,n)&&i.unshift(t),i=i.filter(o)},u=function t(e,o,i){for(var l=[],u=Array.from(e);u.length;){var d=u.shift();if(!a(d,!1))if("SLOT"===d.tagName){var c=d.assignedElements(),f=t(c.length?c:d.children,!0,i);i.flatten?l.push.apply(l,f):l.push({scopeParent:d,candidates:f})}else{r.call(d,n)&&i.filter(d)&&(o||!e.includes(d))&&l.push(d);var s=d.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(d),p=!a(s,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(d));if(s&&p){var h=t(!0===s?d.children:s.children,!0,i);i.flatten?l.push.apply(l,h):l.push({scopeParent:d,candidates:h})}else u.unshift.apply(u,d.children)}}return l},d=function(t,e){return t.tabIndex<0&&(e||/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&isNaN(parseInt(t.getAttribute("tabindex"),10))?0:t.tabIndex},c=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},f=function(t){return"INPUT"===t.tagName},s=function(t){return function(t){return f(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||i(t),o=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=o(window.CSS.escape(t.name));else try{e=o(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var r=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!r||r===t}(t)},p=function(t){var e=t.getBoundingClientRect(),n=e.width,o=e.height;return 0===n&&0===o},h=function(t,e){var n=e.displayCheck,o=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var a=r.call(t,"details>summary:first-of-type")?t.parentElement:t;if(r.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return p(t)}else{if("function"==typeof o){for(var l=t;t;){var u=t.parentElement,d=i(t);if(u&&!u.shadowRoot&&!0===o(u))return p(t);t=t.assignedSlot?t.assignedSlot:u||d===t.ownerDocument?u:d.host}t=l}if(function(t){var e,n,o,r,a=t&&i(t),l=null===(e=a)||void 0===e?void 0:e.host,u=!1;if(a&&a!==t)for(u=!!(null!==(n=l)&&void 0!==n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(l)||null!=t&&null!==(r=t.ownerDocument)&&void 0!==r&&r.contains(t));!u&&l;){var d,c,f;u=!(null===(c=l=null===(d=a=i(l))||void 0===d?void 0:d.host)||void 0===c||null===(f=c.ownerDocument)||void 0===f||!f.contains(l))}return u}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},v=function(t,e){return!(e.disabled||a(e)||function(t){return f(t)&&"hidden"===t.type}(e)||h(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var o=e.children.item(n);if("LEGEND"===o.tagName)return!!r.call(e,"fieldset[disabled] *")||!o.contains(t)}return!0}e=e.parentElement}return!1}(e))},b=function(t,e){return!(s(e)||d(e)<0||!v(t,e))},m=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},y=function t(e){var n=[],o=[];return e.forEach((function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,l=d(a,i),u=i?t(e.candidates):a;0===l?i?n.push.apply(n,u):n.push(a):o.push({documentOrder:r,tabIndex:l,item:e,isScope:i,content:u})})),o.sort(c).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},g=e.concat("iframe").join(",");t.focusable=function(t,e){return(e=e||{}).getShadowRoot?u([t],e.includeContainer,{filter:v.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):l(t,e.includeContainer,v.bind(null,e))},t.isFocusable=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==r.call(t,g)&&v(e,t)},t.isTabbable=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==r.call(t,n)&&b(e,t)},t.tabbable=function(t,e){var n;return n=(e=e||{}).getShadowRoot?u([t],e.includeContainer,{filter:b.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:m}):l(t,e.includeContainer,b.bind(null,e)),y(n)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):(t="undefined"!=typeof globalThis?globalThis:t||self,function(){var n=t.tabbable,o=t.tabbable={};e(o),o.noConflict=function(){return t.tabbable=n,o}}())}(this,(function(t){"use strict";var e=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],n=e.join(","),o="undefined"==typeof Element,r=o?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,i=!o&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},a=function t(e,n){var o;void 0===n&&(n=!0);var r=null==e||null===(o=e.getAttribute)||void 0===o?void 0:o.call(e,"inert");return""===r||"true"===r||n&&e&&t(e.parentNode)},l=function(t,e,o){if(a(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(n));return e&&r.call(t,n)&&i.unshift(t),i=i.filter(o)},u=function t(e,o,i){for(var l=[],u=Array.from(e);u.length;){var d=u.shift();if(!a(d,!1))if("SLOT"===d.tagName){var c=d.assignedElements(),f=t(c.length?c:d.children,!0,i);i.flatten?l.push.apply(l,f):l.push({scopeParent:d,candidates:f})}else{r.call(d,n)&&i.filter(d)&&(o||!e.includes(d))&&l.push(d);var s=d.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(d),p=!a(s,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(d));if(s&&p){var h=t(!0===s?d.children:s.children,!0,i);i.flatten?l.push.apply(l,h):l.push({scopeParent:d,candidates:h})}else u.unshift.apply(u,d.children)}}return l},d=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},c=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&!d(t)?0:t.tabIndex},f=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},s=function(t){return"INPUT"===t.tagName},p=function(t){return function(t){return s(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||i(t),o=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=o(window.CSS.escape(t.name));else try{e=o(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var r=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!r||r===t}(t)},h=function(t){var e=t.getBoundingClientRect(),n=e.width,o=e.height;return 0===n&&0===o},v=function(t,e){var n=e.displayCheck,o=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var a=r.call(t,"details>summary:first-of-type")?t.parentElement:t;if(r.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return h(t)}else{if("function"==typeof o){for(var l=t;t;){var u=t.parentElement,d=i(t);if(u&&!u.shadowRoot&&!0===o(u))return h(t);t=t.assignedSlot?t.assignedSlot:u||d===t.ownerDocument?u:d.host}t=l}if(function(t){var e,n,o,r,a=t&&i(t),l=null===(e=a)||void 0===e?void 0:e.host,u=!1;if(a&&a!==t)for(u=!!(null!==(n=l)&&void 0!==n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(l)||null!=t&&null!==(r=t.ownerDocument)&&void 0!==r&&r.contains(t));!u&&l;){var d,c,f;u=!(null===(c=l=null===(d=a=i(l))||void 0===d?void 0:d.host)||void 0===c||null===(f=c.ownerDocument)||void 0===f||!f.contains(l))}return u}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},b=function(t,e){return!(e.disabled||a(e)||function(t){return s(t)&&"hidden"===t.type}(e)||v(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var o=e.children.item(n);if("LEGEND"===o.tagName)return!!r.call(e,"fieldset[disabled] *")||!o.contains(t)}return!0}e=e.parentElement}return!1}(e))},m=function(t,e){return!(p(e)||c(e)<0||!b(t,e))},g=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},y=function t(e){var n=[],o=[];return e.forEach((function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,l=function(t,e){var n=c(t);return n<0&&e&&!d(t)?0:n}(a,i),u=i?t(e.candidates):a;0===l?i?n.push.apply(n,u):n.push(a):o.push({documentOrder:r,tabIndex:l,item:e,isScope:i,content:u})})),o.sort(f).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},w=e.concat("iframe").join(",");t.focusable=function(t,e){return(e=e||{}).getShadowRoot?u([t],e.includeContainer,{filter:b.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):l(t,e.includeContainer,b.bind(null,e))},t.getTabIndex=c,t.isFocusable=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==r.call(t,w)&&b(e,t)},t.isTabbable=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==r.call(t,n)&&m(e,t)},t.tabbable=function(t,e){var n;return n=(e=e||{}).getShadowRoot?u([t],e.includeContainer,{filter:m.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:g}):l(t,e.includeContainer,m.bind(null,e)),y(n)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.min.js.map |
@@ -23,3 +23,3 @@ type FocusableElement = HTMLElement | SVGElement; | ||
export declare function isTabbable( | ||
element: Element, | ||
node: Element, | ||
options?: CheckOptions | ||
@@ -29,4 +29,8 @@ ): boolean; | ||
export declare function isFocusable( | ||
element: Element, | ||
node: Element, | ||
options?: CheckOptions | ||
): boolean; | ||
export declare function getTabIndex( | ||
node: Element, | ||
): number; |
{ | ||
"name": "tabbable", | ||
"version": "6.1.2", | ||
"version": "6.2.0", | ||
"description": "Returns an array of all tabbable DOM nodes within a containing node.", | ||
@@ -54,18 +54,18 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/focus-trap/tabbable#readme", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/core": "^7.21.8", | ||
"@babel/eslint-parser": "^7.21.8", | ||
"@babel/core": "^7.22.5", | ||
"@babel/eslint-parser": "^7.22.5", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", | ||
"@babel/plugin-proposal-optional-chaining": "^7.20.7", | ||
"@babel/preset-env": "^7.21.5", | ||
"@babel/preset-env": "^7.22.5", | ||
"@changesets/cli": "^2.26.1", | ||
"@cypress/code-coverage": "^3.10.4", | ||
"@cypress/code-coverage": "^3.10.7", | ||
"@rollup/plugin-babel": "^6.0.3", | ||
"@rollup/plugin-commonjs": "^24.1.0", | ||
"@rollup/plugin-node-resolve": "^15.0.2", | ||
"@testing-library/dom": "^9.2.0", | ||
"@rollup/plugin-commonjs": "^25.0.2", | ||
"@rollup/plugin-node-resolve": "^15.1.0", | ||
"@rollup/plugin-terser": "^0.4.3", | ||
"@testing-library/dom": "^9.3.1", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@types/node": "^18.16.3", | ||
"all-contributors-cli": "^6.25.0", | ||
"@types/node": "^20.3.1", | ||
"all-contributors-cli": "^6.26.0", | ||
"babel-jest": "^29.5.0", | ||
@@ -78,8 +78,8 @@ "babel-loader": "^9.1.2", | ||
"cross-env": "^7.0.3", | ||
"cypress": "^12.11.0", | ||
"eslint": "^8.39.0", | ||
"cypress": "^12.15.0", | ||
"eslint": "^8.43.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-cypress": "^2.13.3", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-jest": "^27.2.1", | ||
"eslint-plugin-jest": "^27.2.2", | ||
"jest": "^29.5.0", | ||
@@ -92,6 +92,5 @@ "jest-environment-jsdom": "^29.5.0", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^5.0.4", | ||
"typescript": "^5.1.3", | ||
"watchify": "^4.0.0", | ||
"webpack": "^5.81.0" | ||
"webpack": "^5.87.0" | ||
}, | ||
@@ -98,0 +97,0 @@ "overrides": { |
@@ -28,3 +28,3 @@ # tabbable [![CI](https://github.com/focus-trap/tabbable/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/focus-trap/tabbable/actions?query=workflow:CI+branch:master) [![Codecov](https://img.shields.io/codecov/c/github/focus-trap/tabbable)](https://codecov.io/gh/focus-trap/tabbable) [![license](https://badgen.now.sh/badge/license/MIT)](./LICENSE) | ||
- has a `disabled` attribute | ||
- either the node itself _or an ancestor of it_ is hidden via `display: none` (*see ["Display check"](#display-check) below to modify this behavior) | ||
- either the node itself _or an ancestor of it_ is hidden via `display: none` (*see ["Display check"](#displaycheck-option) below to modify this behavior) | ||
- has `visibility: hidden` style | ||
@@ -74,13 +74,13 @@ - is nested under a closed `<details>` element (with the exception of the first `<summary>` element) | ||
tabbable(rootNode, [options]); | ||
tabbable(container, [options]); | ||
``` | ||
- `rootNode: Node` (**Required**) | ||
- `container: Node` (**Required**) | ||
- `options`: | ||
- All the [common options](#common-options). | ||
- `includeContainer: boolean` (default: false) | ||
- If set to `true`, `rootNode` will be included in the returned tabbable node array, if `rootNode` is tabbable. | ||
- Note that whether this option is true or false, if the `rootNode` is [inert](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert), none of its children (deep) will be considered tabbable. | ||
- If set to `true`, `container` will be included in the returned tabbable node array, if `container` is tabbable. | ||
- Note that whether this option is true or false, if the `container` is [inert](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert), none of its children (deep) will be considered tabbable. | ||
Returns an array of ordered tabbable nodes (i.e. in tab order) within the `rootNode`. | ||
Returns an array of ordered tabbable nodes (i.e. in tab order) within the `container`. | ||
@@ -113,13 +113,13 @@ Summary of ordering principles: | ||
focusable(rootNode, [options]); | ||
focusable(container, [options]); | ||
``` | ||
- `rootNode: Node`: **Required** | ||
- `container: Node`: **Required** | ||
- `options`: | ||
- All the [common options](#common-options). | ||
- `includeContainer: boolean` (default: false) | ||
- If set to `true`, `rootNode` will be included in the returned focusable node array, if `rootNode` is focusable. | ||
- Note that whether this option is true or false, if the `rootNode` is [inert](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert), none of its children (deep) will be considered focusable. | ||
- If set to `true`, `container` will be included in the returned focusable node array, if `container` is focusable. | ||
- Note that whether this option is true or false, if the `container` is [inert](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert), none of its children (deep) will be considered focusable. | ||
Returns an array of focusable nodes within the `rootNode`, in DOM order. This will not match the order in which `tabbable()` returns nodes. | ||
Returns an array of focusable nodes within the `container`, in DOM order. This will not match the order in which `tabbable()` returns nodes. | ||
@@ -142,2 +142,16 @@ ### isFocusable | ||
### getTabIndex | ||
```js | ||
import { getTabIndex } from 'tabbable'; | ||
getTabIndex(node); | ||
``` | ||
- `node: Element` (**Required**) | ||
Returns a negative, 0, or positive number that expresses the node's tab index in the DOM, with exceptions made where there are browser inconsistencies related to `<audio>`, `<video>`, `<details>`, and elements with the `contenteditable="true"` attribute. | ||
The specific exceptions may change over time. See the implementation for specific behavior. | ||
## Common Options | ||
@@ -186,3 +200,3 @@ | ||
- `function`: | ||
- `node` will be a descendent of the `rootNode` given to `tabbable()`, `isTabbable()`, `focusable()`, or `isFocusable()`. | ||
- `node` will be a descendent of the `container` given to `tabbable()`, `isTabbable()`, `focusable()`, or `isFocusable()`. | ||
- Returns: The node's `ShadowRoot` if available, `true` indicating a `ShadowRoot` is attached but not available (i.e. "undisclosed"), or a _falsy_ value indicating there is no shadow attached to the node. | ||
@@ -192,3 +206,3 @@ | ||
> | ||
> Returning `true` from a function will also inform how the node's visibility check is done, causing tabbable to use the __non-zero-area__ [Display Check](#display-check) when determining if it's visible, and so tabbable/focusable. | ||
> Returning `true` from a function will also inform how the node's visibility check is done, causing tabbable to use the __non-zero-area__ [Display Check](#displaycheck-option) when determining if it's visible, and so tabbable/focusable. | ||
@@ -201,3 +215,3 @@ ## More details | ||
- If you're thinking, "Why not just use the right `querySelectorAll`?", you _may_ be on to something ... but, as with most "just" statements, you're probably not. For example, a simple `querySelectorAll` approach will not figure out whether an element is _hidden_, and therefore not actually tabbable. (That said, if you do think Tabbable can be simplified or otherwise improved, I'd love to hear your idea.) | ||
- jQuery UI's `:tabbable` selector ignores elements with height and width of `0`. I'm not sure why — because I've found that I can still tab to those elements. So I kept them in. Only elements hidden with `display: none` or `visibility: hidden` are left out. See ["Display check"](#display-check) below for other options. | ||
- jQuery UI's `:tabbable` selector ignores elements with height and width of `0`. I'm not sure why — because I've found that I can still tab to those elements. So I kept them in. Only elements hidden with `display: none` or `visibility: hidden` are left out. See ["Display check"](#displaycheck-option) below for other options. | ||
- Although Tabbable tries to deal with positive tabindexes, **you should not use positive tabindexes**. Accessibility experts seem to be in (rare) unanimous and clear consent about this: rely on the order of elements in the document. | ||
@@ -216,3 +230,3 @@ - Safari on Mac OS X does not Tab to `<a>` elements by default: you have to change a setting to get the standard behavior. Tabbable does not know whether you've changed that setting or not, so it will include `<a>` elements in its list. | ||
When using test engines such as Jest that use [JSDom](https://github.com/jsdom/jsdom) under the hood in order to run tests in Node.js (as opposed to using an automated browser testing tool like Cypress, Playwright, or Nightwatch where a full DOM is available), it is __highly recommended__ (if not _essential_) to set the [displayCheck](#display-check) option to `none` when calling any of the APIs in this library that accept it. | ||
When using test engines such as Jest that use [JSDom](https://github.com/jsdom/jsdom) under the hood in order to run tests in Node.js (as opposed to using an automated browser testing tool like Cypress, Playwright, or Nightwatch where a full DOM is available), it is __highly recommended__ (if not _essential_) to set the [displayCheck](#displaycheck-option) option to `none` when calling any of the APIs in this library that accept it. | ||
@@ -219,0 +233,0 @@ Using any other `displayCheck` setting will likely lead to failed tests due to nodes expected to be tabbable/focusable being determined to be the opposite because JSDom doesn't fully support some of the DOM APIs being used (even old ones that have been around for a long time). |
@@ -213,3 +213,23 @@ // NOTE: separate `:not()` selectors has broader browser support than the newer | ||
const getTabindex = function (node, isScope) { | ||
/** | ||
* @private | ||
* Determines if the node has an explicitly specified `tabindex` attribute. | ||
* @param {HTMLElement} node | ||
* @returns {boolean} True if so; false if not. | ||
*/ | ||
const hasTabIndex = function (node) { | ||
return !isNaN(parseInt(node.getAttribute('tabindex'), 10)); | ||
}; | ||
/** | ||
* Determine the tab index of a given node. | ||
* @param {HTMLElement} node | ||
* @returns {number} Tab order (negative, 0, or positive number). | ||
* @throws {Error} If `node` is falsy. | ||
*/ | ||
const getTabIndex = function (node) { | ||
if (!node) { | ||
throw new Error('No node provided'); | ||
} | ||
if (node.tabIndex < 0) { | ||
@@ -223,11 +243,6 @@ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default | ||
// so if they don't have a tabindex attribute specifically set, assume it's 0. | ||
// | ||
// isScope is positive for custom element with shadow root or slot that by default | ||
// have tabIndex -1, but need to be sorted by document order in order for their | ||
// content to be inserted in the correct position | ||
if ( | ||
(isScope || | ||
/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || | ||
(/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || | ||
isContentEditable(node)) && | ||
isNaN(parseInt(node.getAttribute('tabindex'), 10)) | ||
!hasTabIndex(node) | ||
) { | ||
@@ -241,2 +256,20 @@ return 0; | ||
/** | ||
* Determine the tab index of a given node __for sort order purposes__. | ||
* @param {HTMLElement} node | ||
* @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default, | ||
* has tabIndex -1, but needs to be sorted by document order in order for its content to be | ||
* inserted into the correct sort position. | ||
* @returns {number} Tab order (negative, 0, or positive number). | ||
*/ | ||
const getSortOrderTabIndex = function (node, isScope) { | ||
const tabIndex = getTabIndex(node); | ||
if (tabIndex < 0 && isScope && !hasTabIndex(node)) { | ||
return 0; | ||
} | ||
return tabIndex; | ||
}; | ||
const sortOrderedTabbables = function (a, b) { | ||
@@ -526,3 +559,3 @@ return a.tabIndex === b.tabIndex | ||
isNonTabbableRadio(node) || | ||
getTabindex(node) < 0 || | ||
getTabIndex(node) < 0 || | ||
!isNodeMatchingSelectorFocusable(options, node) | ||
@@ -555,3 +588,3 @@ ) { | ||
const element = isScope ? item.scopeParent : item; | ||
const candidateTabindex = getTabindex(element, isScope); | ||
const candidateTabindex = getSortOrderTabIndex(element, isScope); | ||
const elements = isScope ? sortByOrder(item.candidates) : element; | ||
@@ -584,3 +617,3 @@ if (candidateTabindex === 0) { | ||
const tabbable = function (el, options) { | ||
const tabbable = function (container, options) { | ||
options = options || {}; | ||
@@ -590,11 +623,15 @@ | ||
if (options.getShadowRoot) { | ||
candidates = getCandidatesIteratively([el], options.includeContainer, { | ||
filter: isNodeMatchingSelectorTabbable.bind(null, options), | ||
flatten: false, | ||
getShadowRoot: options.getShadowRoot, | ||
shadowRootFilter: isValidShadowRootTabbable, | ||
}); | ||
candidates = getCandidatesIteratively( | ||
[container], | ||
options.includeContainer, | ||
{ | ||
filter: isNodeMatchingSelectorTabbable.bind(null, options), | ||
flatten: false, | ||
getShadowRoot: options.getShadowRoot, | ||
shadowRootFilter: isValidShadowRootTabbable, | ||
} | ||
); | ||
} else { | ||
candidates = getCandidates( | ||
el, | ||
container, | ||
options.includeContainer, | ||
@@ -607,3 +644,3 @@ isNodeMatchingSelectorTabbable.bind(null, options) | ||
const focusable = function (el, options) { | ||
const focusable = function (container, options) { | ||
options = options || {}; | ||
@@ -613,10 +650,14 @@ | ||
if (options.getShadowRoot) { | ||
candidates = getCandidatesIteratively([el], options.includeContainer, { | ||
filter: isNodeMatchingSelectorFocusable.bind(null, options), | ||
flatten: true, | ||
getShadowRoot: options.getShadowRoot, | ||
}); | ||
candidates = getCandidatesIteratively( | ||
[container], | ||
options.includeContainer, | ||
{ | ||
filter: isNodeMatchingSelectorFocusable.bind(null, options), | ||
flatten: true, | ||
getShadowRoot: options.getShadowRoot, | ||
} | ||
); | ||
} else { | ||
candidates = getCandidates( | ||
el, | ||
container, | ||
options.includeContainer, | ||
@@ -656,2 +697,2 @@ isNodeMatchingSelectorFocusable.bind(null, options) | ||
export { tabbable, focusable, isTabbable, isFocusable }; | ||
export { tabbable, focusable, isTabbable, isFocusable, getTabIndex }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
411841
2399
288