vendor: 6,602 bytes, lines 1-128
1/*! 2* tabbable 6.2.0 3* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE 4*/ 5(function (global, factory) { 6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : 7 typeof define === 'function' && define.amd ? define(['exports'], factory) : 8 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () { 9 var current = global.tabbable; 10 var exports = global.tabbable = {}; 11 factory(exports); 12 exports.noConflict = function () { global.tabbable = current; return exports; }; 13 })()); 14})(this, (function (exports) { 'use strict'; 15 16 // NOTE: separate `:not()` selectors has broader browser support than the newer 17 // `:not([inert], [inert] *)` (Feb 2023) 18 // CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes 19 // the entire query to fail, resulting in no nodes found, which will break a lot 20 // of things... so we have to rely on JS to identify nodes inside an inert container 21 var candidateSelectors = ['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])']; 22 var candidateSelector = /* #__PURE__ */candidateSelectors.join(','); 23 var NoElement = typeof Element === 'undefined'; 24 var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 25 var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) { 26 var _element$getRootNode; 27 return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element); 28 } : function (element) { 29 return element === null || element === void 0 ? void 0 : element.ownerDocument; 30 }; 31 32 /** 33 * Determines if a node is inert or in an inert ancestor. 34 * @param {Element} [node] 35 * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to 36 * see if any of them are inert. If false, only `node` itself is considered. 37 * @returns {boolean} True if inert itself or by way of being in an inert ancestor. 38 * False if `node` is falsy. 39 */ 40 var isInert = function isInert(node, lookUp) { 41 var _node$getAttribute; 42 if (lookUp === void 0) { 43 lookUp = true; 44 } 45 // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert` 46 // JS API property; we have to check the attribute, which can either be empty or 'true'; 47 // if it's `null` (not specified) or 'false', it's an active element 48 var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, 'inert'); 49 var inert = inertAtt === '' || inertAtt === 'true'; 50 51 // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')` 52 // if it weren't for `matches()` not being a function on shadow roots; the following 53 // code works for any kind of node 54 // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)` 55 // so it likely would not support `:is([inert] *)` either... 56 var result = inert || lookUp && node && isInert(node.parentNode); // recursive 57 58 return result; 59 }; 60 61 /** 62 * Determines if a node's content is editable. 63 * @param {Element} [node] 64 * @returns True if it's content-editable; false if it's not or `node` is falsy. 65 */ 66 var isContentEditable = function isContentEditable(node) { 67 var _node$getAttribute2; 68 // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have 69 // to use the attribute directly to check for this, which can either be empty or 'true'; 70 // if it's `null` (not specified) or 'false', it's a non-editable element 71 var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, 'contenteditable'); 72 return attValue === '' || attValue === 'true'; 73 }; 74 75 /** 76 * @param {Element} el container to check in 77 * @param {boolean} includeContainer add container to check 78 * @param {(node: Element) => boolean} filter filter candidates 79 * @returns {Element[]} 80 */ 81 var getCandidates = function getCandidates(el, includeContainer, filter) { 82 // even if `includeContainer=false`, we still have to check it for inertness because 83 // if it's inert, all its children are inert 84 if (isInert(el)) { 85 return []; 86 } 87 var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector)); 88 if (includeContainer && matches.call(el, candidateSelector)) { 89 candidates.unshift(el); 90 } 91 candidates = candidates.filter(filter); 92 return candidates; 93 }; 94 95 /** 96 * @callback GetShadowRoot 97 * @param {Element} element to check for shadow root 98 * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available. 99 */ 100 101 /** 102 * @callback ShadowRootFilter 103 * @param {Element} shadowHostNode the element which contains shadow content 104 * @returns {boolean} true if a shadow root could potentially contain valid candidates. 105 */ 106 107 /** 108 * @typedef {Object} CandidateScope 109 * @property {Element} scopeParent contains inner candidates 110 * @property {Element[]} candidates list of candidates found in the scope parent 111 */ 112 113 /** 114 * @typedef {Object} IterativeOptions 115 * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not; 116 * if a function, implies shadow support is enabled and either returns the shadow root of an element 117 * or a boolean stating if it has an undisclosed shadow root 118 * @property {(node: Element) => boolean} filter filter candidates 119 * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list 120 * @property {ShadowRootFilter} shadowRootFilter filter shadow roots; 121 */ 122 123 /** 124 * @param {Element[]} elements list of element containers to match candidates from 125 * @param {boolean} includeContainer add container list to check 126 * @param {IterativeOptions} options 127 * @returns {Array.<Element|CandidateScope>} 128 */
vendor: 2,456 bytes, lines 129-175
129 var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) { 130 var candidates = []; 131 var elementsToCheck = Array.from(elements); 132 while (elementsToCheck.length) { 133 var element = elementsToCheck.shift(); 134 if (isInert(element, false)) { 135 // no need to look up since we're drilling down 136 // anything inside this container will also be inert 137 continue; 138 } 139 if (element.tagName === 'SLOT') { 140 // add shadow dom slot scope (slot itself cannot be focusable) 141 var assigned = element.assignedElements(); 142 var content = assigned.length ? assigned : element.children; 143 var nestedCandidates = getCandidatesIteratively(content, true, options); 144 if (options.flatten) { 145 candidates.push.apply(candidates, nestedCandidates); 146 } else { 147 candidates.push({ 148 scopeParent: element, 149 candidates: nestedCandidates 150 }); 151 } 152 } else { 153 // check candidate element 154 var validCandidate = matches.call(element, candidateSelector); 155 if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) { 156 candidates.push(element); 157 } 158 159 // iterate over shadow content if possible 160 var shadowRoot = element.shadowRoot || 161 // check for an undisclosed shadow 162 typeof options.getShadowRoot === 'function' && options.getShadowRoot(element); 163 164 // no inert look up because we're already drilling down and checking for inertness 165 // on the way down, so all containers to this root node should have already been 166 // vetted as non-inert 167 var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element)); 168 if (shadowRoot && validShadowRoot) { 169 // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed 170 // shadow exists, so look at light dom children as fallback BUT create a scope for any 171 // child candidates found because they're likely slotted elements (elements that are 172 // children of the web component element (which has the shadow), in the light dom, but 173 // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below, 174 // _after_ we return from this recursive call 175 var _nestedCandidates =
vendor: 8,859 bytes, lines 175-352
175getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options); 176 if (options.flatten) { 177 candidates.push.apply(candidates, _nestedCandidates); 178 } else { 179 candidates.push({ 180 scopeParent: element, 181 candidates: _nestedCandidates 182 }); 183 } 184 } else { 185 // there's not shadow so just dig into the element's (light dom) children 186 // __without__ giving the element special scope treatment 187 elementsToCheck.unshift.apply(elementsToCheck, element.children); 188 } 189 } 190 } 191 return candidates; 192 }; 193 194 /** 195 * @private 196 * Determines if the node has an explicitly specified `tabindex` attribute. 197 * @param {HTMLElement} node 198 * @returns {boolean} True if so; false if not. 199 */ 200 var hasTabIndex = function hasTabIndex(node) { 201 return !isNaN(parseInt(node.getAttribute('tabindex'), 10)); 202 }; 203 204 /** 205 * Determine the tab index of a given node. 206 * @param {HTMLElement} node 207 * @returns {number} Tab order (negative, 0, or positive number). 208 * @throws {Error} If `node` is falsy. 209 */ 210 var getTabIndex = function getTabIndex(node) { 211 if (!node) { 212 throw new Error('No node provided'); 213 } 214 if (node.tabIndex < 0) { 215 // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default 216 // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM, 217 // yet they are still part of the regular tab order; in FF, they get a default 218 // `tabIndex` of 0; since Chrome still puts those elements in the regular tab 219 // order, consider their tab index to be 0. 220 // Also browsers do not return `tabIndex` correctly for contentEditable nodes; 221 // so if they don't have a tabindex attribute specifically set, assume it's 0. 222 if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) { 223 return 0; 224 } 225 } 226 return node.tabIndex; 227 }; 228 229 /** 230 * Determine the tab index of a given node __for sort order purposes__. 231 * @param {HTMLElement} node 232 * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default, 233 * has tabIndex -1, but needs to be sorted by document order in order for its content to be 234 * inserted into the correct sort position. 235 * @returns {number} Tab order (negative, 0, or positive number). 236 */ 237 var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) { 238 var tabIndex = getTabIndex(node); 239 if (tabIndex < 0 && isScope && !hasTabIndex(node)) { 240 return 0; 241 } 242 return tabIndex; 243 }; 244 var sortOrderedTabbables = function sortOrderedTabbables(a, b) { 245 return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex; 246 }; 247 var isInput = function isInput(node) { 248 return node.tagName === 'INPUT'; 249 }; 250 var isHiddenInput = function isHiddenInput(node) { 251 return isInput(node) && node.type === 'hidden'; 252 }; 253 var isDetailsWithSummary = function isDetailsWithSummary(node) { 254 var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) { 255 return child.tagName === 'SUMMARY'; 256 }); 257 return r; 258 }; 259 var getCheckedRadio = function getCheckedRadio(nodes, form) { 260 for (var i = 0; i < nodes.length; i++) { 261 if (nodes[i].checked && nodes[i].form === form) { 262 return nodes[i]; 263 } 264 } 265 }; 266 var isTabbableRadio = function isTabbableRadio(node) { 267 if (!node.name) { 268 return true; 269 } 270 var radioScope = node.form || getRootNode(node); 271 var queryRadios = function queryRadios(name) { 272 return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]'); 273 }; 274 var radioSet; 275 if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') { 276 radioSet = queryRadios(window.CSS.escape(node.name)); 277 } else { 278 try { 279 radioSet = queryRadios(node.name); 280 } catch (err) { 281 // eslint-disable-next-line no-console 282 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', err.message); 283 return false; 284 } 285 } 286 var checked = getCheckedRadio(radioSet, node.form); 287 return !checked || checked === node; 288 }; 289 var isRadio = function isRadio(node) { 290 return isInput(node) && node.type === 'radio'; 291 }; 292 var isNonTabbableRadio = function isNonTabbableRadio(node) { 293 return isRadio(node) && !isTabbableRadio(node); 294 }; 295 296 // determines if a node is ultimately attached to the window's document 297 var isNodeAttached = function isNodeAttached(node) { 298 var _nodeRoot; 299 // The root node is the shadow root if the node is in a shadow DOM; some document otherwise 300 // (but NOT _the_ document; see second 'If' comment below for more). 301 // If rootNode is shadow root, it'll have a host, which is the element to which the shadow 302 // is attached, and the one we need to check if it's in the document or not (because the 303 // shadow, and all nodes it contains, is never considered in the document since shadows 304 // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document, 305 // is hidden, or is not in the document itself but is detached, it will affect the shadow's 306 // visibility, including all the nodes it contains). The host could be any normal node, 307 // or a custom element (i.e. web component). Either way, that's the one that is considered 308 // part of the document, not the shadow root, nor any of its children (i.e. the node being 309 // tested). 310 // To further complicate things, we have to look all the way up until we find a shadow HOST 311 // that is attached (or find none) because the node might be in nested shadows... 312 // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the 313 // document (per the docs) and while it's a Document-type object, that document does not 314 // appear to be the same as the node's `ownerDocument` for some reason, so it's safer 315 // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise, 316 // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when 317 // node is actually detached. 318 // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible 319 // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed 320 // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then 321 // `ownerDocument` will be `null`, hence the optional chaining on it. 322 var nodeRoot = node && getRootNode(node); 323 var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host; 324 325 // in some cases, a detached node will return itself as the root instead of a document or 326 // shadow root object, in which case, we shouldn't try to look further up the host chain 327 var attached = false; 328 if (nodeRoot && nodeRoot !== node) { 329 var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument; 330 attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node)); 331 while (!attached && nodeRootHost) { 332 var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD; 333 // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM, 334 // which means we need to get the host's host and check if that parent host is contained 335 // in (i.e. attached to) the document 336 nodeRoot = getRootNode(nodeRootHost); 337 nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host; 338 attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost)); 339 } 340 } 341 return attached; 342 }; 343 var isZeroArea = function isZeroArea(node) { 344 var _node$getBoundingClie = node.getBoundingClientRect(), 345 width = _node$getBoundingClie.width, 346 height = _node$getBoundingClie.height; 347 return width === 0 && height === 0; 348 }; 349 var isHidden = function isHidden(node, _ref) { 350 var displayCheck = _ref.displayCheck, 351 getShadowRoot = _ref.getShadowRoot; 352
vendor: 4,379 bytes, lines 352-430
352// NOTE: visibility will be `undefined` if node is detached from the document 353 // (see notes about this further down), which means we will consider it visible 354 // (this is legacy behavior from a very long way back) 355 // NOTE: we check this regardless of `displayCheck="none"` because this is a 356 // _visibility_ check, not a _display_ check 357 if (getComputedStyle(node).visibility === 'hidden') { 358 return true; 359 } 360 var isDirectSummary = matches.call(node, 'details>summary:first-of-type'); 361 var nodeUnderDetails = isDirectSummary ? node.parentElement : node; 362 if (matches.call(nodeUnderDetails, 'details:not([open]) *')) { 363 return true; 364 } 365 if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') { 366 if (typeof getShadowRoot === 'function') { 367 // figure out if we should consider the node to be in an undisclosed shadow and use the 368 // 'non-zero-area' fallback 369 var originalNode = node; 370 while (node) { 371 var parentElement = node.parentElement; 372 var rootNode = getRootNode(node); 373 if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow 374 ) { 375 // node has an undisclosed shadow which means we can only treat it as a black box, so we 376 // fall back to a non-zero-area test 377 return isZeroArea(node); 378 } else if (node.assignedSlot) { 379 // iterate up slot 380 node = node.assignedSlot; 381 } else if (!parentElement && rootNode !== node.ownerDocument) { 382 // cross shadow boundary 383 node = rootNode.host; 384 } else { 385 // iterate up normal dom 386 node = parentElement; 387 } 388 } 389 node = originalNode; 390 } 391 // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support 392 // (i.e. it does not also presume that all nodes might have undisclosed shadows); or 393 // it might be a falsy value, which means shadow DOM support is disabled 394 395 // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled) 396 // now we can just test to see if it would normally be visible or not, provided it's 397 // attached to the main document. 398 // NOTE: We must consider case where node is inside a shadow DOM and given directly to 399 // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting. 400 401 if (isNodeAttached(node)) { 402 // this works wherever the node is: if there's at least one client rect, it's 403 // somehow displayed; it also covers the CSS 'display: contents' case where the 404 // node itself is hidden in place of its contents; and there's no need to search 405 // up the hierarchy either 406 return !node.getClientRects().length; 407 } 408 409 // Else, the node isn't attached to the document, which means the `getClientRects()` 410 // API will __always__ return zero rects (this can happen, for example, if React 411 // is used to render nodes onto a detached tree, as confirmed in this thread: 412 // https://github.com/facebook/react/issues/9117#issuecomment-284228870) 413 // 414 // It also means that even window.getComputedStyle(node).display will return `undefined` 415 // because styles are only computed for nodes that are in the document. 416 // 417 // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable 418 // somehow. Though it was never stated officially, anyone who has ever used tabbable 419 // APIs on nodes in detached containers has actually implicitly used tabbable in what 420 // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially 421 // considering __everything__ to be visible because of the innability to determine styles. 422 // 423 // v6.0.0: As of this major release, the default 'full' option __no longer treats detached 424 // nodes as visible with the 'none' fallback.__ 425 if (displayCheck !== 'legacy-full') { 426 return true; // hidden 427 } 428 // else, fallback to 'none' mode and consider the node visible 429 } else if (displayCheck === 'non-zero-area') { 430 // NOTE: Even though this tests that the node's client rect is non-zero to determine
vendor: 4,415 bytes, lines 431-533
431 // whether it's displayed, and that a detached node will __always__ have a zero-area 432 // client rect, we don't special-case for whether the node is attached or not. In 433 // this mode, we do want to consider nodes that have a zero area to be hidden at all 434 // times, and that includes attached or not. 435 return isZeroArea(node); 436 } 437 438 // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume 439 // it's visible 440 return false; 441 }; 442 443 // form fields (nested) inside a disabled fieldset are not focusable/tabbable 444 // unless they are in the _first_ <legend> element of the top-most disabled 445 // fieldset 446 var isDisabledFromFieldset = function isDisabledFromFieldset(node) { 447 if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) { 448 var parentNode = node.parentElement; 449 // check if `node` is contained in a disabled <fieldset> 450 while (parentNode) { 451 if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) { 452 // look for the first <legend> among the children of the disabled <fieldset> 453 for (var i = 0; i < parentNode.children.length; i++) { 454 var child = parentNode.children.item(i); 455 // when the first <legend> (in document order) is found 456 if (child.tagName === 'LEGEND') { 457 // if its parent <fieldset> is not nested in another disabled <fieldset>, 458 // return whether `node` is a descendant of its first <legend> 459 return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node); 460 } 461 } 462 // the disabled <fieldset> containing `node` has no <legend> 463 return true; 464 } 465 parentNode = parentNode.parentElement; 466 } 467 } 468 469 // else, node's tabbable/focusable state should not be affected by a fieldset's 470 // enabled/disabled state 471 return false; 472 }; 473 var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) { 474 if (node.disabled || 475 // we must do an inert look up to filter out any elements inside an inert ancestor 476 // because we're limited in the type of selectors we can use in JSDom (see related 477 // note related to `candidateSelectors`) 478 isInert(node) || isHiddenInput(node) || isHidden(node, options) || 479 // For a details element with a summary, the summary element gets the focus 480 isDetailsWithSummary(node) || isDisabledFromFieldset(node)) { 481 return false; 482 } 483 return true; 484 }; 485 var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) { 486 if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) { 487 return false; 488 } 489 return true; 490 }; 491 var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) { 492 var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10); 493 if (isNaN(tabIndex) || tabIndex >= 0) { 494 return true; 495 } 496 // If a custom element has an explicit negative tabindex, 497 // browsers will not allow tab targeting said element's children. 498 return false; 499 }; 500 501 /** 502 * @param {Array.<Element|CandidateScope>} candidates 503 * @returns Element[] 504 */ 505 var sortByOrder = function sortByOrder(candidates) { 506 var regularTabbables = []; 507 var orderedTabbables = []; 508 candidates.forEach(function (item, i) { 509 var isScope = !!item.scopeParent; 510 var element = isScope ? item.scopeParent : item; 511 var candidateTabindex = getSortOrderTabIndex(element, isScope); 512 var elements = isScope ? sortByOrder(item.candidates) : element; 513 if (candidateTabindex === 0) { 514 isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element); 515 } else { 516 orderedTabbables.push({ 517 documentOrder: i, 518 tabIndex: candidateTabindex, 519 item: item, 520 isScope: isScope, 521 content: elements 522 }); 523 } 524 }); 525 return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) { 526 sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content); 527 return acc; 528 }, []).concat(regularTabbables); 529 }; 530 var tabbable = function tabbable(container, options) { 531 options = options || {}; 532 var candidates; 533 if (options.getShadowRoot) {
vendor: 2,003 bytes, lines 534-590
534 candidates = getCandidatesIteratively([container], options.includeContainer, { 535 filter: isNodeMatchingSelectorTabbable.bind(null, options), 536 flatten: false, 537 getShadowRoot: options.getShadowRoot, 538 shadowRootFilter: isValidShadowRootTabbable 539 }); 540 } else { 541 candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options)); 542 } 543 return sortByOrder(candidates); 544 }; 545 var focusable = function focusable(container, options) { 546 options = options || {}; 547 var candidates; 548 if (options.getShadowRoot) { 549 candidates = getCandidatesIteratively([container], options.includeContainer, { 550 filter: isNodeMatchingSelectorFocusable.bind(null, options), 551 flatten: true, 552 getShadowRoot: options.getShadowRoot 553 }); 554 } else { 555 candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options)); 556 } 557 return candidates; 558 }; 559 var isTabbable = function isTabbable(node, options) { 560 options = options || {}; 561 if (!node) { 562 throw new Error('No node provided'); 563 } 564 if (matches.call(node, candidateSelector) === false) { 565 return false; 566 } 567 return isNodeMatchingSelectorTabbable(options, node); 568 }; 569 var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(','); 570 var isFocusable = function isFocusable(node, options) { 571 options = options || {}; 572 if (!node) { 573 throw new Error('No node provided'); 574 } 575 if (matches.call(node, focusableCandidateSelector) === false) { 576 return false; 577 } 578 return isNodeMatchingSelectorFocusable(options, node); 579 }; 580 581 exports.focusable = focusable; 582 exports.getTabIndex = getTabIndex; 583 exports.isFocusable = isFocusable; 584 exports.isTabbable = isTabbable; 585 exports.tabbable = tabbable; 586 587 Object.defineProperty(exports, '__esModule', { value: true }); 588 589})); 590//# sourceMappingURL=index.umd.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.