Comparing version 5.3.2 to 5.3.3
# Changelog | ||
## 5.3.3 | ||
### Patch Changes | ||
- 0210a1c: fix: align with browser behaviour when a web component has a negative tabindex | ||
## 5.3.2 | ||
@@ -4,0 +10,0 @@ |
/*! | ||
* tabbable 5.3.2 | ||
* tabbable 5.3.3 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
@@ -38,2 +38,8 @@ */ | ||
/** | ||
* @callback ShadowRootFilter | ||
* @param {Element} shadowHostNode the element which contains shadow content | ||
* @returns {boolean} true if a shadow root could potentially contain valid candidates. | ||
*/ | ||
/** | ||
* @typedef {Object} CandidatesScope | ||
@@ -51,2 +57,3 @@ * @property {Element} scope contains inner candidates | ||
* @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list | ||
* @property {ShadowRootFilter} shadowRootFilter filter shadow roots; | ||
*/ | ||
@@ -94,4 +101,5 @@ | ||
typeof options.getShadowRoot === 'function' && options.getShadowRoot(element); | ||
var validShadowRoot = !options.shadowRootFilter || options.shadowRootFilter(element); | ||
if (shadowRoot) { | ||
if (shadowRoot && validShadowRoot) { | ||
// add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed | ||
@@ -377,2 +385,14 @@ // shadow exists, so look at light dom children as fallback BUT create a scope for any | ||
}; | ||
var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) { | ||
var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10); | ||
if (isNaN(tabIndex) || tabIndex >= 0) { | ||
return true; | ||
} // If a custom element has an explicit negative tabindex, | ||
// browsers will not allow tab targeting said element's children. | ||
return false; | ||
}; | ||
/** | ||
@@ -419,3 +439,4 @@ * @param {Array.<Element|CandidatesScope>} candidates | ||
flatten: false, | ||
getShadowRoot: options.getShadowRoot | ||
getShadowRoot: options.getShadowRoot, | ||
shadowRootFilter: isValidShadowRootTabbable | ||
}); | ||
@@ -422,0 +443,0 @@ } else { |
/*! | ||
* tabbable 5.3.2 | ||
* tabbable 5.3.3 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
*/ | ||
var e=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],t=e.join(","),n="undefined"==typeof Element,o=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,r=!n&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},a=function(e,n,r){var a=Array.prototype.slice.apply(e.querySelectorAll(t));return n&&o.call(e,t)&&a.unshift(e),a=a.filter(r)},i=function e(n,r,a){for(var i=[],u=Array.from(n);u.length;){var l=u.shift();if("SLOT"===l.tagName){var c=l.assignedElements(),d=e(c.length?c:l.children,!0,a);a.flatten?i.push.apply(i,d):i.push({scope:l,candidates:d})}else{o.call(l,t)&&a.filter(l)&&(r||!n.includes(l))&&i.push(l);var f=l.shadowRoot||"function"==typeof a.getShadowRoot&&a.getShadowRoot(l);if(f){var s=e(!0===f?l.children:f.children,!0,a);a.flatten?i.push.apply(i,s):i.push({scope:l,candidates:s})}else u.unshift.apply(u,l.children)}}return i},u=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},l=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},c=function(e){return"INPUT"===e.tagName},d=function(e){return function(e){return c(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||r(e),o=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=o(window.CSS.escape(e.name));else try{t=o(e.name)}catch(e){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",e.message),!1}var a=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!a||a===e}(e)},f=function(e){var t=e.getBoundingClientRect(),n=t.width,o=t.height;return 0===n&&0===o},s=function(e,t){return!(t.disabled||function(e){return c(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,a=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var i=o.call(e,"details>summary:first-of-type")?e.parentElement:e;if(o.call(i,"details:not([open]) *"))return!0;var u=r(e).host,l=(null==u?void 0:u.ownerDocument.contains(u))||e.ownerDocument.contains(e);if(n&&"full"!==n){if("non-zero-area"===n)return f(e)}else{if("function"==typeof a){for(var c=e;e;){var d=e.parentElement,s=r(e);if(d&&!d.shadowRoot&&!0===a(d))return f(e);e=e.assignedSlot?e.assignedSlot:d||s===e.ownerDocument?d:s.host}e=c}if(l)return!e.getClientRects().length}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!o.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},p=function(e,t){return!(d(t)||u(t)<0||!s(e,t))},h=function(e,t){return function e(t){var n=[],o=[];return t.forEach((function(t,r){var a=!!t.scope,i=a?t.scope:t,l=u(i,a),c=a?e(t.candidates):i;0===l?a?n.push.apply(n,c):n.push(i):o.push({documentOrder:r,tabIndex:l,item:t,isScope:a,content:c})})),o.sort(l).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)}((t=t||{}).getShadowRoot?i([e],t.includeContainer,{filter:p.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,p.bind(null,t)))},m=function(e,t){return(t=t||{}).getShadowRoot?i([e],t.includeContainer,{filter:s.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,s.bind(null,t))},y=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return!1!==o.call(e,t)&&p(n,e)},g=e.concat("iframe").join(","),S=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==o.call(e,g)&&s(t,e)};export{m as focusable,S as isFocusable,y as isTabbable,h as tabbable}; | ||
var e=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],t=e.join(","),n="undefined"==typeof Element,o=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,r=!n&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},a=function(e,n,r){var a=Array.prototype.slice.apply(e.querySelectorAll(t));return n&&o.call(e,t)&&a.unshift(e),a=a.filter(r)},i=function e(n,r,a){for(var i=[],u=Array.from(n);u.length;){var l=u.shift();if("SLOT"===l.tagName){var c=l.assignedElements(),d=e(c.length?c:l.children,!0,a);a.flatten?i.push.apply(i,d):i.push({scope:l,candidates:d})}else{o.call(l,t)&&a.filter(l)&&(r||!n.includes(l))&&i.push(l);var s=l.shadowRoot||"function"==typeof a.getShadowRoot&&a.getShadowRoot(l),f=!a.shadowRootFilter||a.shadowRootFilter(l);if(s&&f){var p=e(!0===s?l.children:s.children,!0,a);a.flatten?i.push.apply(i,p):i.push({scope:l,candidates:p})}else u.unshift.apply(u,l.children)}}return i},u=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},l=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},c=function(e){return"INPUT"===e.tagName},d=function(e){return function(e){return c(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||r(e),o=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=o(window.CSS.escape(e.name));else try{t=o(e.name)}catch(e){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",e.message),!1}var a=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!a||a===e}(e)},s=function(e){var t=e.getBoundingClientRect(),n=t.width,o=t.height;return 0===n&&0===o},f=function(e,t){return!(t.disabled||function(e){return c(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,a=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var i=o.call(e,"details>summary:first-of-type")?e.parentElement:e;if(o.call(i,"details:not([open]) *"))return!0;var u=r(e).host,l=(null==u?void 0:u.ownerDocument.contains(u))||e.ownerDocument.contains(e);if(n&&"full"!==n){if("non-zero-area"===n)return s(e)}else{if("function"==typeof a){for(var c=e;e;){var d=e.parentElement,f=r(e);if(d&&!d.shadowRoot&&!0===a(d))return s(e);e=e.assignedSlot?e.assignedSlot:d||f===e.ownerDocument?d:f.host}e=c}if(l)return!e.getClientRects().length}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!o.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},p=function(e,t){return!(d(t)||u(t)<0||!f(e,t))},h=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},m=function(e,t){return function e(t){var n=[],o=[];return t.forEach((function(t,r){var a=!!t.scope,i=a?t.scope:t,l=u(i,a),c=a?e(t.candidates):i;0===l?a?n.push.apply(n,c):n.push(i):o.push({documentOrder:r,tabIndex:l,item:t,isScope:a,content:c})})),o.sort(l).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)}((t=t||{}).getShadowRoot?i([e],t.includeContainer,{filter:p.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:h}):a(e,t.includeContainer,p.bind(null,t)))},g=function(e,t){return(t=t||{}).getShadowRoot?i([e],t.includeContainer,{filter:f.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,f.bind(null,t))},y=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return!1!==o.call(e,t)&&p(n,e)},S=e.concat("iframe").join(","),w=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==o.call(e,S)&&f(t,e)};export{g as focusable,w as isFocusable,y as isTabbable,m as tabbable}; | ||
//# sourceMappingURL=index.esm.min.js.map |
/*! | ||
* tabbable 5.3.2 | ||
* tabbable 5.3.3 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
@@ -42,2 +42,8 @@ */ | ||
/** | ||
* @callback ShadowRootFilter | ||
* @param {Element} shadowHostNode the element which contains shadow content | ||
* @returns {boolean} true if a shadow root could potentially contain valid candidates. | ||
*/ | ||
/** | ||
* @typedef {Object} CandidatesScope | ||
@@ -55,2 +61,3 @@ * @property {Element} scope contains inner candidates | ||
* @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list | ||
* @property {ShadowRootFilter} shadowRootFilter filter shadow roots; | ||
*/ | ||
@@ -98,4 +105,5 @@ | ||
typeof options.getShadowRoot === 'function' && options.getShadowRoot(element); | ||
var validShadowRoot = !options.shadowRootFilter || options.shadowRootFilter(element); | ||
if (shadowRoot) { | ||
if (shadowRoot && validShadowRoot) { | ||
// add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed | ||
@@ -381,2 +389,14 @@ // shadow exists, so look at light dom children as fallback BUT create a scope for any | ||
}; | ||
var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) { | ||
var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10); | ||
if (isNaN(tabIndex) || tabIndex >= 0) { | ||
return true; | ||
} // If a custom element has an explicit negative tabindex, | ||
// browsers will not allow tab targeting said element's children. | ||
return false; | ||
}; | ||
/** | ||
@@ -423,3 +443,4 @@ * @param {Array.<Element|CandidatesScope>} candidates | ||
flatten: false, | ||
getShadowRoot: options.getShadowRoot | ||
getShadowRoot: options.getShadowRoot, | ||
shadowRootFilter: isValidShadowRootTabbable | ||
}); | ||
@@ -426,0 +447,0 @@ } else { |
/*! | ||
* tabbable 5.3.2 | ||
* tabbable 5.3.3 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],t=e.join(","),n="undefined"==typeof Element,o=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,r=!n&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},a=function(e,n,r){var a=Array.prototype.slice.apply(e.querySelectorAll(t));return n&&o.call(e,t)&&a.unshift(e),a=a.filter(r)},i=function e(n,r,a){for(var i=[],l=Array.from(n);l.length;){var u=l.shift();if("SLOT"===u.tagName){var c=u.assignedElements(),d=e(c.length?c:u.children,!0,a);a.flatten?i.push.apply(i,d):i.push({scope:u,candidates:d})}else{o.call(u,t)&&a.filter(u)&&(r||!n.includes(u))&&i.push(u);var s=u.shadowRoot||"function"==typeof a.getShadowRoot&&a.getShadowRoot(u);if(s){var f=e(!0===s?u.children:s.children,!0,a);a.flatten?i.push.apply(i,f):i.push({scope:u,candidates:f})}else l.unshift.apply(l,u.children)}}return i},l=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},u=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},c=function(e){return"INPUT"===e.tagName},d=function(e){return function(e){return c(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||r(e),o=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=o(window.CSS.escape(e.name));else try{t=o(e.name)}catch(e){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",e.message),!1}var a=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!a||a===e}(e)},s=function(e){var t=e.getBoundingClientRect(),n=t.width,o=t.height;return 0===n&&0===o},f=function(e,t){return!(t.disabled||function(e){return c(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,a=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var i=o.call(e,"details>summary:first-of-type")?e.parentElement:e;if(o.call(i,"details:not([open]) *"))return!0;var l=r(e).host,u=(null==l?void 0:l.ownerDocument.contains(l))||e.ownerDocument.contains(e);if(n&&"full"!==n){if("non-zero-area"===n)return s(e)}else{if("function"==typeof a){for(var c=e;e;){var d=e.parentElement,f=r(e);if(d&&!d.shadowRoot&&!0===a(d))return s(e);e=e.assignedSlot?e.assignedSlot:d||f===e.ownerDocument?d:f.host}e=c}if(u)return!e.getClientRects().length}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!o.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},p=function(e,t){return!(d(t)||l(t)<0||!f(e,t))},h=e.concat("iframe").join(",");exports.focusable=function(e,t){return(t=t||{}).getShadowRoot?i([e],t.includeContainer,{filter:f.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,f.bind(null,t))},exports.isFocusable=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==o.call(e,h)&&f(t,e)},exports.isTabbable=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return!1!==o.call(e,t)&&p(n,e)},exports.tabbable=function(e,t){return function e(t){var n=[],o=[];return t.forEach((function(t,r){var a=!!t.scope,i=a?t.scope:t,u=l(i,a),c=a?e(t.candidates):i;0===u?a?n.push.apply(n,c):n.push(i):o.push({documentOrder:r,tabIndex:u,item:t,isScope:a,content:c})})),o.sort(u).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)}((t=t||{}).getShadowRoot?i([e],t.includeContainer,{filter:p.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,p.bind(null,t)))}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],t=e.join(","),n="undefined"==typeof Element,o=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,r=!n&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},a=function(e,n,r){var a=Array.prototype.slice.apply(e.querySelectorAll(t));return n&&o.call(e,t)&&a.unshift(e),a=a.filter(r)},i=function e(n,r,a){for(var i=[],l=Array.from(n);l.length;){var u=l.shift();if("SLOT"===u.tagName){var c=u.assignedElements(),d=e(c.length?c:u.children,!0,a);a.flatten?i.push.apply(i,d):i.push({scope:u,candidates:d})}else{o.call(u,t)&&a.filter(u)&&(r||!n.includes(u))&&i.push(u);var s=u.shadowRoot||"function"==typeof a.getShadowRoot&&a.getShadowRoot(u),f=!a.shadowRootFilter||a.shadowRootFilter(u);if(s&&f){var p=e(!0===s?u.children:s.children,!0,a);a.flatten?i.push.apply(i,p):i.push({scope:u,candidates:p})}else l.unshift.apply(l,u.children)}}return i},l=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},u=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},c=function(e){return"INPUT"===e.tagName},d=function(e){return function(e){return c(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||r(e),o=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=o(window.CSS.escape(e.name));else try{t=o(e.name)}catch(e){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",e.message),!1}var a=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!a||a===e}(e)},s=function(e){var t=e.getBoundingClientRect(),n=t.width,o=t.height;return 0===n&&0===o},f=function(e,t){return!(t.disabled||function(e){return c(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,a=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var i=o.call(e,"details>summary:first-of-type")?e.parentElement:e;if(o.call(i,"details:not([open]) *"))return!0;var l=r(e).host,u=(null==l?void 0:l.ownerDocument.contains(l))||e.ownerDocument.contains(e);if(n&&"full"!==n){if("non-zero-area"===n)return s(e)}else{if("function"==typeof a){for(var c=e;e;){var d=e.parentElement,f=r(e);if(d&&!d.shadowRoot&&!0===a(d))return s(e);e=e.assignedSlot?e.assignedSlot:d||f===e.ownerDocument?d:f.host}e=c}if(u)return!e.getClientRects().length}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!o.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},p=function(e,t){return!(d(t)||l(t)<0||!f(e,t))},h=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},m=e.concat("iframe").join(",");exports.focusable=function(e,t){return(t=t||{}).getShadowRoot?i([e],t.includeContainer,{filter:f.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,f.bind(null,t))},exports.isFocusable=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==o.call(e,m)&&f(t,e)},exports.isTabbable=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return!1!==o.call(e,t)&&p(n,e)},exports.tabbable=function(e,t){return function e(t){var n=[],o=[];return t.forEach((function(t,r){var a=!!t.scope,i=a?t.scope:t,u=l(i,a),c=a?e(t.candidates):i;0===u?a?n.push.apply(n,c):n.push(i):o.push({documentOrder:r,tabIndex:u,item:t,isScope:a,content:c})})),o.sort(u).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)}((t=t||{}).getShadowRoot?i([e],t.includeContainer,{filter:p.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:h}):a(e,t.includeContainer,p.bind(null,t)))}; | ||
//# sourceMappingURL=index.min.js.map |
/*! | ||
* tabbable 5.3.2 | ||
* tabbable 5.3.3 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
@@ -49,2 +49,8 @@ */ | ||
/** | ||
* @callback ShadowRootFilter | ||
* @param {Element} shadowHostNode the element which contains shadow content | ||
* @returns {boolean} true if a shadow root could potentially contain valid candidates. | ||
*/ | ||
/** | ||
* @typedef {Object} CandidatesScope | ||
@@ -62,2 +68,3 @@ * @property {Element} scope contains inner candidates | ||
* @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list | ||
* @property {ShadowRootFilter} shadowRootFilter filter shadow roots; | ||
*/ | ||
@@ -105,4 +112,5 @@ | ||
typeof options.getShadowRoot === 'function' && options.getShadowRoot(element); | ||
var validShadowRoot = !options.shadowRootFilter || options.shadowRootFilter(element); | ||
if (shadowRoot) { | ||
if (shadowRoot && validShadowRoot) { | ||
// add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed | ||
@@ -388,2 +396,14 @@ // shadow exists, so look at light dom children as fallback BUT create a scope for any | ||
}; | ||
var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) { | ||
var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10); | ||
if (isNaN(tabIndex) || tabIndex >= 0) { | ||
return true; | ||
} // If a custom element has an explicit negative tabindex, | ||
// browsers will not allow tab targeting said element's children. | ||
return false; | ||
}; | ||
/** | ||
@@ -430,3 +450,4 @@ * @param {Array.<Element|CandidatesScope>} candidates | ||
flatten: false, | ||
getShadowRoot: options.getShadowRoot | ||
getShadowRoot: options.getShadowRoot, | ||
shadowRootFilter: isValidShadowRootTabbable | ||
}); | ||
@@ -433,0 +454,0 @@ } else { |
/*! | ||
* tabbable 5.3.2 | ||
* tabbable 5.3.3 | ||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.tabbable,o=e.tabbable={};t(o),o.noConflict=function(){return e.tabbable=n,o}}())}(this,(function(e){"use strict";var t=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],n=t.join(","),o="undefined"==typeof Element,r=o?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,i=!o&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},a=function(e,t,o){var i=Array.prototype.slice.apply(e.querySelectorAll(n));return t&&r.call(e,n)&&i.unshift(e),i=i.filter(o)},l=function e(t,o,i){for(var a=[],l=Array.from(t);l.length;){var u=l.shift();if("SLOT"===u.tagName){var c=u.assignedElements(),d=e(c.length?c:u.children,!0,i);i.flatten?a.push.apply(a,d):a.push({scope:u,candidates:d})}else{r.call(u,n)&&i.filter(u)&&(o||!t.includes(u))&&a.push(u);var f=u.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(u);if(f){var s=e(!0===f?u.children:f.children,!0,i);i.flatten?a.push.apply(a,s):a.push({scope:u,candidates:s})}else l.unshift.apply(l,u.children)}}return a},u=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},c=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},d=function(e){return"INPUT"===e.tagName},f=function(e){return function(e){return d(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||i(e),o=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=o(window.CSS.escape(e.name));else try{t=o(e.name)}catch(e){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",e.message),!1}var r=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!r||r===e}(e)},s=function(e){var t=e.getBoundingClientRect(),n=t.width,o=t.height;return 0===n&&0===o},p=function(e,t){return!(t.disabled||function(e){return d(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,o=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var a=r.call(e,"details>summary:first-of-type")?e.parentElement:e;if(r.call(a,"details:not([open]) *"))return!0;var l=i(e).host,u=(null==l?void 0:l.ownerDocument.contains(l))||e.ownerDocument.contains(e);if(n&&"full"!==n){if("non-zero-area"===n)return s(e)}else{if("function"==typeof o){for(var c=e;e;){var d=e.parentElement,f=i(e);if(d&&!d.shadowRoot&&!0===o(d))return s(e);e=e.assignedSlot?e.assignedSlot:d||f===e.ownerDocument?d:f.host}e=c}if(u)return!e.getClientRects().length}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var o=t.children.item(n);if("LEGEND"===o.tagName)return!!r.call(t,"fieldset[disabled] *")||!o.contains(e)}return!0}t=t.parentElement}return!1}(t))},h=function(e,t){return!(f(t)||u(t)<0||!p(e,t))},m=t.concat("iframe").join(",");e.focusable=function(e,t){return(t=t||{}).getShadowRoot?l([e],t.includeContainer,{filter:p.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,p.bind(null,t))},e.isFocusable=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==r.call(e,m)&&p(t,e)},e.isTabbable=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==r.call(e,n)&&h(t,e)},e.tabbable=function(e,t){return function e(t){var n=[],o=[];return t.forEach((function(t,r){var i=!!t.scope,a=i?t.scope:t,l=u(a,i),c=i?e(t.candidates):a;0===l?i?n.push.apply(n,c):n.push(a):o.push({documentOrder:r,tabIndex:l,item:t,isScope:i,content:c})})),o.sort(c).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)}((t=t||{}).getShadowRoot?l([e],t.includeContainer,{filter:h.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,h.bind(null,t)))},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.tabbable,o=e.tabbable={};t(o),o.noConflict=function(){return e.tabbable=n,o}}())}(this,(function(e){"use strict";var t=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],n=t.join(","),o="undefined"==typeof Element,r=o?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,i=!o&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},a=function(e,t,o){var i=Array.prototype.slice.apply(e.querySelectorAll(n));return t&&r.call(e,n)&&i.unshift(e),i=i.filter(o)},l=function e(t,o,i){for(var a=[],l=Array.from(t);l.length;){var u=l.shift();if("SLOT"===u.tagName){var c=u.assignedElements(),d=e(c.length?c:u.children,!0,i);i.flatten?a.push.apply(a,d):a.push({scope:u,candidates:d})}else{r.call(u,n)&&i.filter(u)&&(o||!t.includes(u))&&a.push(u);var f=u.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(u),s=!i.shadowRootFilter||i.shadowRootFilter(u);if(f&&s){var p=e(!0===f?u.children:f.children,!0,i);i.flatten?a.push.apply(a,p):a.push({scope:u,candidates:p})}else l.unshift.apply(l,u.children)}}return a},u=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},c=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},d=function(e){return"INPUT"===e.tagName},f=function(e){return function(e){return d(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||i(e),o=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=o(window.CSS.escape(e.name));else try{t=o(e.name)}catch(e){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",e.message),!1}var r=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!r||r===e}(e)},s=function(e){var t=e.getBoundingClientRect(),n=t.width,o=t.height;return 0===n&&0===o},p=function(e,t){return!(t.disabled||function(e){return d(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,o=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var a=r.call(e,"details>summary:first-of-type")?e.parentElement:e;if(r.call(a,"details:not([open]) *"))return!0;var l=i(e).host,u=(null==l?void 0:l.ownerDocument.contains(l))||e.ownerDocument.contains(e);if(n&&"full"!==n){if("non-zero-area"===n)return s(e)}else{if("function"==typeof o){for(var c=e;e;){var d=e.parentElement,f=i(e);if(d&&!d.shadowRoot&&!0===o(d))return s(e);e=e.assignedSlot?e.assignedSlot:d||f===e.ownerDocument?d:f.host}e=c}if(u)return!e.getClientRects().length}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var o=t.children.item(n);if("LEGEND"===o.tagName)return!!r.call(t,"fieldset[disabled] *")||!o.contains(e)}return!0}t=t.parentElement}return!1}(t))},h=function(e,t){return!(f(t)||u(t)<0||!p(e,t))},b=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},m=t.concat("iframe").join(",");e.focusable=function(e,t){return(t=t||{}).getShadowRoot?l([e],t.includeContainer,{filter:p.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):a(e,t.includeContainer,p.bind(null,t))},e.isFocusable=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==r.call(e,m)&&p(t,e)},e.isTabbable=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==r.call(e,n)&&h(t,e)},e.tabbable=function(e,t){return function e(t){var n=[],o=[];return t.forEach((function(t,r){var i=!!t.scope,a=i?t.scope:t,l=u(a,i),c=i?e(t.candidates):a;0===l?i?n.push.apply(n,c):n.push(a):o.push({documentOrder:r,tabIndex:l,item:t,isScope:i,content:c})})),o.sort(c).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)}((t=t||{}).getShadowRoot?l([e],t.includeContainer,{filter:h.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:b}):a(e,t.includeContainer,h.bind(null,t)))},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "tabbable", | ||
"version": "5.3.2", | ||
"version": "5.3.3", | ||
"description": "Returns an array of all tabbable DOM nodes within a containing node.", | ||
@@ -55,7 +55,7 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.17.10", | ||
"@babel/core": "^7.18.2", | ||
"@babel/eslint-parser": "^7.17.0", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.17.12", | ||
"@babel/plugin-proposal-optional-chaining": "^7.16.0", | ||
"@babel/preset-env": "^7.17.10", | ||
"@babel/preset-env": "^7.18.0", | ||
"@changesets/cli": "^2.22.0", | ||
@@ -68,5 +68,5 @@ "@cypress/code-coverage": "^3.9.12", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@types/node": "^17.0.31", | ||
"@types/node": "^17.0.35", | ||
"all-contributors-cli": "^6.20.0", | ||
"babel-jest": "^28.0.3", | ||
"babel-jest": "^28.1.0", | ||
"brfs": "^2.0.2", | ||
@@ -76,17 +76,18 @@ "browserify": "^17.0.0", | ||
"cross-env": "^7.0.3", | ||
"cypress": "^9.6.0", | ||
"eslint": "^8.14.0", | ||
"cypress": "^9.7.0", | ||
"eslint": "^8.16.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-cypress": "^2.12.1", | ||
"eslint-plugin-import": "^2.26.0", | ||
"jest": "^28.0.3", | ||
"eslint-plugin-jest": "^26.2.2", | ||
"jest": "^28.1.0", | ||
"jest-watch-typeahead": "^1.1.0", | ||
"onchange": "^7.1.0", | ||
"prettier": "^2.6.2", | ||
"rollup": "^2.71.1", | ||
"rollup": "^2.74.1", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.6.4", | ||
"typescript": "^4.7.2", | ||
"watchify": "^4.0.0" | ||
} | ||
} |
# 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) | ||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors) | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
@@ -229,2 +229,3 @@ | ||
<td align="center"><a href="https://github.com/tidychips"><img src="https://avatars2.githubusercontent.com/u/11446636?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bryan Murphy</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/issues?q=author%3Atidychips" title="Bug reports">๐</a> <a href="https://github.com/focus-trap/tabbable/commits?author=tidychips" title="Code">๐ป</a></td> | ||
<td align="center"><a href="https://github.com/craigkovatch"><img src="https://avatars.githubusercontent.com/u/10970257?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Craig Kovatch</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/issues?q=author%3Acraigkovatch" title="Bug reports">๐</a></td> | ||
<td align="center"><a href="https://github.com/DaviDevMod"><img src="https://avatars.githubusercontent.com/u/98312056?v=4?s=100" width="100px;" alt=""/><br /><sub><b>DaviDevMod</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/issues?q=author%3ADaviDevMod" title="Bug reports">๐</a> <a href="https://github.com/focus-trap/tabbable/commits?author=DaviDevMod" title="Code">๐ป</a> <a href="https://github.com/focus-trap/tabbable/commits?author=DaviDevMod" title="Tests">โ ๏ธ</a> <a href="https://github.com/focus-trap/tabbable/commits?author=DaviDevMod" title="Documentation">๐</a></td> | ||
@@ -235,8 +236,9 @@ <td align="center"><a href="http://davidtheclark.com/"><img src="https://avatars2.githubusercontent.com/u/628431?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Clark</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/commits?author=davidtheclark" title="Code">๐ป</a> <a href="https://github.com/focus-trap/tabbable/issues?q=author%3Adavidtheclark" title="Bug reports">๐</a> <a href="#infra-davidtheclark" title="Infrastructure (Hosting, Build-Tools, etc)">๐</a> <a href="https://github.com/focus-trap/tabbable/commits?author=davidtheclark" title="Tests">โ ๏ธ</a> <a href="https://github.com/focus-trap/tabbable/commits?author=davidtheclark" title="Documentation">๐</a> <a href="#maintenance-davidtheclark" title="Maintenance">๐ง</a></td> | ||
<td align="center"><a href="http://www.khamilton.co.uk"><img src="https://avatars1.githubusercontent.com/u/4013283?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kristian Hamilton</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/issues?q=author%3Akhamiltonuk" title="Bug reports">๐</a></td> | ||
<td align="center"><a href="https://github.com/Andarist"><img src="https://avatars2.githubusercontent.com/u/9800850?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mateusz Burzyลski</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/commits?author=Andarist" title="Code">๐ป</a> <a href="https://github.com/focus-trap/tabbable/issues?q=author%3AAndarist" title="Bug reports">๐</a> <a href="https://github.com/focus-trap/tabbable/commits?author=Andarist" title="Documentation">๐</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="https://github.com/Andarist"><img src="https://avatars2.githubusercontent.com/u/9800850?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mateusz Burzyลski</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/commits?author=Andarist" title="Code">๐ป</a> <a href="https://github.com/focus-trap/tabbable/issues?q=author%3AAndarist" title="Bug reports">๐</a> <a href="https://github.com/focus-trap/tabbable/commits?author=Andarist" title="Documentation">๐</a></td> | ||
<td align="center"><a href="https://github.com/rvsia"><img src="https://avatars.githubusercontent.com/u/32869456?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Richard Vลกianskรฝ</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/commits?author=rvsia" title="Documentation">๐</a></td> | ||
<td align="center"><a href="https://stefancameron.com/"><img src="https://avatars3.githubusercontent.com/u/2855350?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefan Cameron</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/commits?author=stefcameron" title="Code">๐ป</a> <a href="https://github.com/focus-trap/tabbable/issues?q=author%3Astefcameron" title="Bug reports">๐</a> <a href="#infra-stefcameron" title="Infrastructure (Hosting, Build-Tools, etc)">๐</a> <a href="https://github.com/focus-trap/tabbable/commits?author=stefcameron" title="Tests">โ ๏ธ</a> <a href="https://github.com/focus-trap/tabbable/commits?author=stefcameron" title="Documentation">๐</a> <a href="#maintenance-stefcameron" title="Maintenance">๐ง</a></td> | ||
<td align="center"><a href="http://tylerhawkins.info/201R/"><img src="https://avatars0.githubusercontent.com/u/13806458?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler Hawkins</b></sub></a><br /><a href="#tool-thawkin3" title="Tools">๐ง</a> <a href="https://github.com/focus-trap/tabbable/commits?author=thawkin3" title="Tests">โ ๏ธ</a> <a href="#infra-thawkin3" title="Infrastructure (Hosting, Build-Tools, etc)">๐</a> <a href="https://github.com/focus-trap/tabbable/commits?author=thawkin3" title="Documentation">๐</a></td> | ||
<td align="center"><a href="https://github.com/BFrost"><img src="https://avatars.githubusercontent.com/u/3368761?v=4?s=100" width="100px;" alt=""/><br /><sub><b>bfrost</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/issues?q=author%3ABFrost" title="Bug reports">๐</a></td> | ||
<td align="center"><a href="https://github.com/pebble2050"><img src="https://avatars1.githubusercontent.com/u/47210889?v=4?s=100" width="100px;" alt=""/><br /><sub><b>pebble2050</b></sub></a><br /><a href="https://github.com/focus-trap/tabbable/issues?q=author%3Apebble2050" title="Bug reports">๐</a></td> | ||
@@ -243,0 +245,0 @@ </tr> |
@@ -53,2 +53,8 @@ const candidateSelectors = [ | ||
/** | ||
* @callback ShadowRootFilter | ||
* @param {Element} shadowHostNode the element which contains shadow content | ||
* @returns {boolean} true if a shadow root could potentially contain valid candidates. | ||
*/ | ||
/** | ||
* @typedef {Object} CandidatesScope | ||
@@ -66,2 +72,3 @@ * @property {Element} scope contains inner candidates | ||
* @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list | ||
* @property {ShadowRootFilter} shadowRootFilter filter shadow roots; | ||
*/ | ||
@@ -115,3 +122,6 @@ | ||
if (shadowRoot) { | ||
const validShadowRoot = | ||
!options.shadowRootFilter || options.shadowRootFilter(element); | ||
if (shadowRoot && validShadowRoot) { | ||
// add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed | ||
@@ -421,2 +431,12 @@ // shadow exists, so look at light dom children as fallback BUT create a scope for any | ||
const isValidShadowRootTabbable = function (shadowHostNode) { | ||
const tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10); | ||
if (isNaN(tabIndex) || tabIndex >= 0) { | ||
return true; | ||
} | ||
// If a custom element has an explicit negative tabindex, | ||
// browsers will not allow tab targeting said element's children. | ||
return false; | ||
}; | ||
/** | ||
@@ -469,2 +489,3 @@ * @param {Array.<Element|CandidatesScope>} candidates | ||
getShadowRoot: options.getShadowRoot, | ||
shadowRootFilter: isValidShadowRootTabbable, | ||
}); | ||
@@ -471,0 +492,0 @@ } else { |
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
320397
1829
250
34