accessible-name-and-description.js.map 36.6 KB
{"version":3,"sources":["../sources/accessible-name-and-description.ts"],"names":["asFlatString","s","trim","replace","isHidden","node","getComputedStyleImplementation","hasAttribute","getAttribute","style","getPropertyValue","isControl","hasAbstractRole","role","TypeError","querySelectorAllSubtree","element","selectors","elements","querySelectorAll","forEach","root","push","apply","querySelectedOptions","listbox","selectedOptions","isMarkedPresentational","isNativeHostLanguageTextAlternativeElement","allowsNameFromContent","isDescendantOfNativeHostLanguageTextAlternativeElement","computeTooltipAttributeValue","getValueOfTextbox","value","textContent","getTextualContent","declaration","content","test","slice","isLabelableElement","localName","findLabelableElement","labelableElement","childNodes","childNode","descendantLabelableElement","getControlOfLabel","label","control","undefined","htmlFor","ownerDocument","getElementById","getLabels","labelsProperty","labels","document","filter","getSlotContents","slot","assignedNodes","length","computeTextAlternative","options","consultedNodes","SetLike","window","compute","computedStyleSupportsPseudoElements","getComputedStyle","bind","hidden","computeMiscTextAlternative","context","accumulatedText","pseudoBefore","beforeContent","concat","child","result","isEmbeddedInLabel","isReferenced","recursion","display","separator","pseudoAfter","afterContent","computeElementTextAlternative","useAttribute","attributeName","attribute","getAttributeNode","has","add","children","i","nameFromAlt","nameFromLabel","type","nameFromValue","map","join","nameFromTitle","nameFromSubTree","current","labelElements","skipToStep2E","ariaLabel","elementTextAlternative","selectedOption","nodeType","TEXT_NODE","tooltipAttributeValue"],"mappings":";;;;;AAGA;;AACA;;AACA;;;;AALA;AACA;AACA;;AAmDA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAT,CAAsBC,CAAtB,EAA6C;AAC5C,SAAOA,CAAC,CAACC,IAAF,GAASC,OAAT,CAAiB,QAAjB,EAA2B,GAA3B,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,QAAT,CACCC,IADD,EAECC,8BAFD,EAGmB;AAClB,MAAI,CAAC,qBAAUD,IAAV,CAAL,EAAsB;AACrB,WAAO,KAAP;AACA;;AAED,MACCA,IAAI,CAACE,YA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,EAAuB;AACtBlB,MAAAA,cAAc,CAAC6B,GAAf,CAAmBW,OAAnB;AACA,aAAOhC,0BAA0B,CAACgC,OAAD,EAAU;AAC1CxB,QAAAA,iBAAiB,EAAEP,OAAO,CAACO,iBADe;AAE1CC,QAAAA,YAAY,EAAE;AAF4B,OAAV,CAAjC;AAIA;;AAED,QAAM+B,qBAAqB,GAAGlF,4BAA4B,CAAC0E,OAAD,CAA1D;;AACA,QAAIQ,qBAAqB,KAAK,IAA9B,EAAoC;AACnChD,MAAAA,cAAc,CAAC6B,GAAf,CAAmBW,OAAnB;AACA,aAAOQ,qBAAP;AACA,KAzIQ,CA2IT;;;AACAhD,IAAAA,cAAc,CAAC6B,GAAf,CAAmBW,OAAnB;AACA,WAAO,EAAP;AACA;;AAED,SAAOzG,YAAY,CAClB+D,sBAAsB,CAAC1C,IAAD,EAAO;AAC5B4D,IAAAA,iBAAiB,EAAE,KADS;AAE5B;AACAC,IAAAA,YAAY,EAAEd,OAAO,KAAK,aAHE;AAI5Be,IAAAA,SAAS,EAAE;AAJiB,GAAP,CADJ,CAAnB;AAQA","sourcesContent":["/**\n * implements https://w3c.github.io/accname/\n */\nimport ArrayFrom from \"./polyfills/array.from\";\nimport SetLike from \"./polyfills/SetLike\";\nimport {\n\thasAnyConcreteRoles,\n\tisElement,\n\tisHTMLTableCaptionElement,\n\tisHTMLInputElement,\n\tisHTMLSelectElement,\n\tisHTMLTextAreaElement,\n\tsafeWindow,\n\tisHTMLFieldSetElement,\n\tisHTMLLegendElement,\n\tisHTMLOptGroupElement,\n\tisHTMLTableElement,\n\tisHTMLSlotElement,\n\tisSVGSVGElement,\n\tisSVGTitleElement,\n\tqueryIdRefs,\n\tgetLocalName,\n} from \"./util\";\n\n/**\n *  A string of characters where all carriage returns, newlines, tabs, and form-feeds are replaced with a single space, and multiple spaces are reduced to a single space. The string contains only character data; it does not contain any markup.\n */\ntype FlatString = string & {\n\t__flat: true;\n};\n\n/**\n * interface for an options-bag where `window.getComputedStyle` can be mocked\n */\nexport interface ComputeTextAlternativeOptions {\n\tcompute?: \"description\" | \"name\";\n\t/**\n\t * Set to true if window.computedStyle supports the second argument.\n\t * This should be false in JSDOM. Otherwise JSDOM will log console errors.\n\t */\n\tcomputedStyleSupportsPseudoElements?: boolean;\n\t/**\n\t * mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n\t */\n\tgetComputedStyle?: typeof window.getComputedStyle;\n\t/**\n\t * Set to `true` if you want to include hidden elements in the accessible name and description computation.\n\t * Skips 2A in https://w3c.github.io/accname/#computation-steps.\n\t * @default false\n\t */\n\thidden?: boolean;\n}\n\n/**\n *\n * @param {string} string -\n * @returns {FlatString} -\n */\nfunction asFlatString(s: string): FlatString {\n\treturn s.trim().replace(/\\s\\s+/g, \" \") as FlatString;\n}\n\n/**\n *\n * @param node -\n * @param options - These are not optional to prevent accidentally calling it without options in `computeAccessibleName`\n * @returns {boolean} -\n */\nfunction isHidden(\n\tnode: Node,\n\tgetComputedStyleImplementation: typeof window.getComputedStyle\n): node is Element {\n\tif (!isElement(node)) {\n\t\treturn false;\n\t}\n\n\tif (\n\t\tnode.hasAttribute(\"hidden\") ||\n\t\tnode.getAttribute(\"aria-hidden\") === \"true\"\n\t) {\n\t\treturn true;\n\t}\n\n\tconst style = getComputedStyleImplementation(node);\n\treturn (\n\t\tstyle.getPropertyValue(\"display\") === \"none\" ||\n\t\tstyle.getPropertyValue(\"visibility\") === \"hidden\"\n\t);\n}\n\n/**\n * @param {Node} node -\n * @returns {boolean} - As defined in step 2E of https://w3c.github.io/accname/#mapping_additional_nd_te\n */\nfunction isControl(node: Node): boolean {\n\treturn (\n\t\thasAnyConcreteRoles(node, [\"button\", \"combobox\", \"listbox\", \"textbox\"]) ||\n\t\thasAbstractRole(node, \"range\")\n\t);\n}\n\nfunction hasAbstractRole(node: Node, role: string): node is Element {\n\tif (!isElement(node)) {\n\t\treturn false;\n\t}\n\n\tswitch (role) {\n\t\tcase \"range\":\n\t\t\treturn hasAnyConcreteRoles(node, [\n\t\t\t\t\"meter\",\n\t\t\t\t\"progressbar\",\n\t\t\t\t\"scrollbar\",\n\t\t\t\t\"slider\",\n\t\t\t\t\"spinbutton\",\n\t\t\t]);\n\t\tdefault:\n\t\t\tthrow new TypeError(\n\t\t\t\t`No knowledge about abstract role '${role}'. This is likely a bug :(`\n\t\t\t);\n\t}\n}\n\n/**\n * element.querySelectorAll but also considers owned tree\n * @param element\n * @param selectors\n */\nfunction querySelectorAllSubtree(\n\telement: Element,\n\tselectors: string\n): Element[] {\n\tconst elements = ArrayFrom(element.querySelectorAll(selectors));\n\n\tqueryIdRefs(element, \"aria-owns\").forEach((root) => {\n\t\t// babel transpiles this assuming an iterator\n\t\telements.push.apply(elements, ArrayFrom(root.querySelectorAll(selectors)));\n\t});\n\n\treturn elements;\n}\n\nfunction querySelectedOptions(listbox: Element): ArrayLike<Element> {\n\tif (isHTMLSelectElement(listbox)) {\n\t\t// IE11 polyfill\n\t\treturn (\n\t\t\tlistbox.selectedOptions || querySelectorAllSubtree(listbox, \"[selected]\")\n\t\t);\n\t}\n\treturn querySelectorAllSubtree(listbox, '[aria-selected=\"true\"]');\n}\n\nfunction isMarkedPresentational(node: Node): node is Element {\n\treturn hasAnyConcreteRoles(node, [\"none\", \"presentation\"]);\n}\n\n/**\n * Elements specifically listed in html-aam\n *\n * We don't need this for `label` or `legend` elements.\n * Their implicit roles already allow \"naming from content\".\n *\n * sources:\n *\n * - https://w3c.github.io/html-aam/#table-element\n */\nfunction isNativeHostLanguageTextAlternativeElement(\n\tnode: Node\n): node is Element {\n\treturn isHTMLTableCaptionElement(node);\n}\n\n/**\n * https://w3c.github.io/aria/#namefromcontent\n */\nfunction allowsNameFromContent(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"button\",\n\t\t\"cell\",\n\t\t\"checkbox\",\n\t\t\"columnheader\",\n\t\t\"gridcell\",\n\t\t\"heading\",\n\t\t\"label\",\n\t\t\"legend\",\n\t\t\"link\",\n\t\t\"menuitem\",\n\t\t\"menuitemcheckbox\",\n\t\t\"menuitemradio\",\n\t\t\"option\",\n\t\t\"radio\",\n\t\t\"row\",\n\t\t\"rowheader\",\n\t\t\"switch\",\n\t\t\"tab\",\n\t\t\"tooltip\",\n\t\t\"treeitem\",\n\t]);\n}\n\n/**\n * TODO https://github.com/eps1lon/dom-accessibility-api/issues/100\n */\nfunction isDescendantOfNativeHostLanguageTextAlternativeElement(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet\n\tnode: Node\n): boolean {\n\treturn false;\n}\n\n/**\n * TODO https://github.com/eps1lon/dom-accessibility-api/issues/101\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet\nfunction computeTooltipAttributeValue(node: Node): string | null {\n\treturn null;\n}\n\nfunction getValueOfTextbox(element: Element): string {\n\tif (isHTMLInputElement(element) || isHTMLTextAreaElement(element)) {\n\t\treturn element.value;\n\t}\n\t// https://github.com/eps1lon/dom-accessibility-api/issues/4\n\treturn element.textContent || \"\";\n}\n\nfunction getTextualContent(declaration: CSSStyleDeclaration): string {\n\tconst content = declaration.getPropertyValue(\"content\");\n\tif (/^[\"'].*[\"']$/.test(content)) {\n\t\treturn content.slice(1, -1);\n\t}\n\treturn \"\";\n}\n\n/**\n * https://html.spec.whatwg.org/multipage/forms.html#category-label\n * TODO: form-associated custom elements\n * @param element\n */\nfunction isLabelableElement(element: Element): boolean {\n\tconst localName = getLocalName(element);\n\n\treturn (\n\t\tlocalName === \"button\" ||\n\t\t(localName === \"input\" && element.getAttribute(\"type\") !== \"hidden\") ||\n\t\tlocalName === \"meter\" ||\n\t\tlocalName === \"output\" ||\n\t\tlocalName === \"progress\" ||\n\t\tlocalName === \"select\" ||\n\t\tlocalName === \"textarea\"\n\t);\n}\n\n/**\n * > [...], then the first such descendant in tree order is the label element's labeled control.\n * -- https://html.spec.whatwg.org/multipage/forms.html#labeled-control\n * @param element\n */\nfunction findLabelableElement(element: Element): Element | null {\n\tif (isLabelableElement(element)) {\n\t\treturn element;\n\t}\n\tlet labelableElement: Element | null = null;\n\telement.childNodes.forEach((childNode) => {\n\t\tif (labelableElement === null && isElement(childNode)) {\n\t\t\tconst descendantLabelableElement = findLabelableElement(childNode);\n\t\t\tif (descendantLabelableElement !== null) {\n\t\t\t\tlabelableElement = descendantLabelableElement;\n\t\t\t}\n\t\t}\n\t});\n\n\treturn labelableElement;\n}\n\n/**\n * Polyfill of HTMLLabelElement.control\n * https://html.spec.whatwg.org/multipage/forms.html#labeled-control\n * @param label\n */\nfunction getControlOfLabel(label: HTMLLabelElement): Element | null {\n\tif (label.control !== undefined) {\n\t\treturn label.control;\n\t}\n\n\tconst htmlFor = label.getAttribute(\"for\");\n\tif (htmlFor !== null) {\n\t\treturn label.ownerDocument.getElementById(htmlFor);\n\t}\n\n\treturn findLabelableElement(label);\n}\n\n/**\n * Polyfill of HTMLInputElement.labels\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels\n * @param element\n */\nfunction getLabels(element: Element): HTMLLabelElement[] | null {\n\tconst labelsProperty = (element as any).labels as\n\t\t| undefined\n\t\t| null\n\t\t| NodeListOf<HTMLLabelElement>;\n\tif (labelsProperty === null) {\n\t\treturn labelsProperty;\n\t}\n\tif (labelsProperty !== undefined) {\n\t\treturn ArrayFrom(labelsProperty);\n\t}\n\n\t// polyfill\n\tif (!isLabelableElement(element)) {\n\t\treturn null;\n\t}\n\tconst document = element.ownerDocument;\n\n\treturn ArrayFrom(document.querySelectorAll(\"label\")).filter((label) => {\n\t\treturn getControlOfLabel(label) === element;\n\t});\n}\n\n/**\n * Gets the contents of a slot used for computing the accname\n * @param slot\n */\nfunction getSlotContents(slot: HTMLSlotElement): Node[] {\n\t// Computing the accessible name for elements containing slots is not\n\t// currently defined in the spec. This implementation reflects the\n\t// behavior of NVDA 2020.2/Firefox 81 and iOS VoiceOver/Safari 13.6.\n\tconst assignedNodes = slot.assignedNodes();\n\tif (assignedNodes.length === 0) {\n\t\t// if no nodes are assigned to the slot, it displays the default content\n\t\treturn ArrayFrom(slot.childNodes);\n\t}\n\treturn assignedNodes;\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_te\n * @param root\n * @param options\n * @returns\n */\nexport function computeTextAlternative(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tconst consultedNodes = new SetLike<Node>();\n\n\tconst window = safeWindow(root);\n\tconst {\n\t\tcompute = \"name\",\n\t\tcomputedStyleSupportsPseudoElements = options.getComputedStyle !==\n\t\t\tundefined,\n\t\t// This might be overengineered. I don't know what happens if I call\n\t\t// window.getComputedStyle(elementFromAnotherWindow) or if I don't bind it\n\t\t// the type declarations don't require a `this`\n\t\t// eslint-disable-next-line no-restricted-properties\n\t\tgetComputedStyle = window.getComputedStyle.bind(window),\n\t\thidden = false,\n\t} = options;\n\n\t// 2F.i\n\tfunction computeMiscTextAlternative(\n\t\tnode: Node,\n\t\tcontext: { isEmbeddedInLabel: boolean; isReferenced: boolean }\n\t): string {\n\t\tlet accumulatedText = \"\";\n\t\tif (isElement(node) && computedStyleSupportsPseudoElements) {\n\t\t\tconst pseudoBefore = getComputedStyle(node, \"::before\");\n\t\t\tconst beforeContent = getTextualContent(pseudoBefore);\n\t\t\taccumulatedText = `${beforeContent} ${accumulatedText}`;\n\t\t}\n\n\t\t// FIXME: Including aria-owns is not defined in the spec\n\t\t// But it is required in the web-platform-test\n\t\tconst childNodes = isHTMLSlotElement(node)\n\t\t\t? getSlotContents(node)\n\t\t\t: ArrayFrom(node.childNodes).concat(queryIdRefs(node, \"aria-owns\"));\n\t\tchildNodes.forEach((child) => {\n\t\t\tconst result = computeTextAlternative(child, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t\trecursion: true,\n\t\t\t});\n\t\t\t// TODO: Unclear why display affects delimiter\n\t\t\t// see https://github.com/w3c/accname/issues/3\n\t\t\tconst display = isElement(child)\n\t\t\t\t? getComputedStyle(child).getPropertyValue(\"display\")\n\t\t\t\t: \"inline\";\n\t\t\tconst separator = display !== \"inline\" ? \" \" : \"\";\n\t\t\t// trailing separator for wpt tests\n\t\t\taccumulatedText += `${separator}${result}${separator}`;\n\t\t});\n\n\t\tif (isElement(node) && computedStyleSupportsPseudoElements) {\n\t\t\tconst pseudoAfter = getComputedStyle(node, \"::after\");\n\t\t\tconst afterContent = getTextualContent(pseudoAfter);\n\t\t\taccumulatedText = `${accumulatedText} ${afterContent}`;\n\t\t}\n\n\t\treturn accumulatedText.trim();\n\t}\n\n\tfunction computeElementTextAlternative(node: Node): string | null {\n\t\tif (!isElement(node)) {\n\t\t\treturn null;\n\t\t}\n\n\t\t/**\n\t\t *\n\t\t * @param element\n\t\t * @param attributeName\n\t\t * @returns A string non-empty string or `null`\n\t\t */\n\t\tfunction useAttribute(\n\t\t\telement: Element,\n\t\t\tattributeName: string\n\t\t): string | null {\n\t\t\tconst attribute = element.getAttributeNode(attributeName);\n\t\t\tif (\n\t\t\t\tattribute !== null &&\n\t\t\t\t!consultedNodes.has(attribute) &&\n\t\t\t\tattribute.value.trim() !== \"\"\n\t\t\t) {\n\t\t\t\tconsultedNodes.add(attribute);\n\t\t\t\treturn attribute.value;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\n\t\t// https://w3c.github.io/html-aam/#fieldset-and-legend-elements\n\t\tif (isHTMLFieldSetElement(node)) {\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isHTMLLegendElement(child)) {\n\t\t\t\t\treturn computeTextAlternative(child, {\n\t\t\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isHTMLTableElement(node)) {\n\t\t\t// https://w3c.github.io/html-aam/#table-element\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isHTMLTableCaptionElement(child)) {\n\t\t\t\t\treturn computeTextAlternative(child, {\n\t\t\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isSVGSVGElement(node)) {\n\t\t\t// https://www.w3.org/TR/svg-aam-1.0/\n\t\t\tconsultedNodes.add(node);\n\t\t\tconst children = ArrayFrom(node.childNodes);\n\t\t\tfor (let i = 0; i < children.length; i += 1) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (isSVGTitleElement(child)) {\n\t\t\t\t\treturn child.textContent;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t} else if (getLocalName(node) === \"img\" || getLocalName(node) === \"area\") {\n\t\t\t// https://w3c.github.io/html-aam/#area-element\n\t\t\t// https://w3c.github.io/html-aam/#img-element\n\t\t\tconst nameFromAlt = useAttribute(node, \"alt\");\n\t\t\tif (nameFromAlt !== null) {\n\t\t\t\treturn nameFromAlt;\n\t\t\t}\n\t\t} else if (isHTMLOptGroupElement(node)) {\n\t\t\tconst nameFromLabel = useAttribute(node, \"label\");\n\t\t\tif (nameFromLabel !== null) {\n\t\t\t\treturn nameFromLabel;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tisHTMLInputElement(node) &&\n\t\t\t(node.type === \"button\" ||\n\t\t\t\tnode.type === \"submit\" ||\n\t\t\t\tnode.type === \"reset\")\n\t\t) {\n\t\t\t// https://w3c.github.io/html-aam/#input-type-text-input-type-password-input-type-search-input-type-tel-input-type-email-input-type-url-and-textarea-element-accessible-description-computation\n\t\t\tconst nameFromValue = useAttribute(node, \"value\");\n\t\t\tif (nameFromValue !== null) {\n\t\t\t\treturn nameFromValue;\n\t\t\t}\n\n\t\t\t// TODO: l10n\n\t\t\tif (node.type === \"submit\") {\n\t\t\t\treturn \"Submit\";\n\t\t\t}\n\t\t\t// TODO: l10n\n\t\t\tif (node.type === \"reset\") {\n\t\t\t\treturn \"Reset\";\n\t\t\t}\n\t\t}\n\n\t\tconst labels = getLabels(node);\n\t\tif (labels !== null && labels.length !== 0) {\n\t\t\tconsultedNodes.add(node);\n\t\t\treturn ArrayFrom(labels)\n\t\t\t\t.map((element) => {\n\t\t\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t\t\tisEmbeddedInLabel: true,\n\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\trecursion: true,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.filter((label) => {\n\t\t\t\t\treturn label.length > 0;\n\t\t\t\t})\n\t\t\t\t.join(\" \");\n\t\t}\n\n\t\t// https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation\n\t\t// TODO: wpt test consider label elements but html-aam does not mention them\n\t\t// We follow existing implementations over spec\n\t\tif (isHTMLInputElement(node) && node.type === \"image\") {\n\t\t\tconst nameFromAlt = useAttribute(node, \"alt\");\n\t\t\tif (nameFromAlt !== null) {\n\t\t\t\treturn nameFromAlt;\n\t\t\t}\n\n\t\t\tconst nameFromTitle = useAttribute(node, \"title\");\n\t\t\tif (nameFromTitle !== null) {\n\t\t\t\treturn nameFromTitle;\n\t\t\t}\n\n\t\t\t// TODO: l10n\n\t\t\treturn \"Submit Query\";\n\t\t}\n\n\t\tif (hasAnyConcreteRoles(node, [\"button\"])) {\n\t\t\t// https://www.w3.org/TR/html-aam-1.0/#button-element\n\t\t\tconst nameFromSubTree = computeMiscTextAlternative(node, {\n\t\t\t\tisEmbeddedInLabel: false,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t\tif (nameFromSubTree !== \"\") {\n\t\t\t\treturn nameFromSubTree;\n\t\t\t}\n\t\t\treturn useAttribute(node, \"title\");\n\t\t}\n\n\t\treturn useAttribute(node, \"title\");\n\t}\n\n\tfunction computeTextAlternative(\n\t\tcurrent: Node,\n\t\tcontext: {\n\t\t\tisEmbeddedInLabel: boolean;\n\t\t\tisReferenced: boolean;\n\t\t\trecursion: boolean;\n\t\t}\n\t): string {\n\t\tif (consultedNodes.has(current)) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\t// 2A\n\t\tif (\n\t\t\t!hidden &&\n\t\t\tisHidden(current, getComputedStyle) &&\n\t\t\t!context.isReferenced\n\t\t) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn \"\" as FlatString;\n\t\t}\n\n\t\t// 2B\n\t\tconst labelElements = queryIdRefs(current, \"aria-labelledby\");\n\t\tif (\n\t\t\tcompute === \"name\" &&\n\t\t\t!context.isReferenced &&\n\t\t\tlabelElements.length > 0\n\t\t) {\n\t\t\treturn labelElements\n\t\t\t\t.map((element) =>\n\t\t\t\t\tcomputeTextAlternative(element, {\n\t\t\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\t\t\tisReferenced: true,\n\t\t\t\t\t\t// thais isn't recursion as specified, otherwise we would skip\n\t\t\t\t\t\t// `aria-label` in\n\t\t\t\t\t\t// <input id=\"myself\" aria-label=\"foo\" aria-labelledby=\"myself\"\n\t\t\t\t\t\trecursion: false,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t.join(\" \");\n\t\t}\n\n\t\t// 2C\n\t\t// Changed from the spec in anticipation of https://github.com/w3c/accname/issues/64\n\t\t// spec says we should only consider skipping if we have a non-empty label\n\t\tconst skipToStep2E =\n\t\t\tcontext.recursion && isControl(current) && compute === \"name\";\n\t\tif (!skipToStep2E) {\n\t\t\tconst ariaLabel = (\n\t\t\t\t(isElement(current) && current.getAttribute(\"aria-label\")) ||\n\t\t\t\t\"\"\n\t\t\t).trim();\n\t\t\tif (ariaLabel !== \"\" && compute === \"name\") {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\treturn ariaLabel;\n\t\t\t}\n\n\t\t\t// 2D\n\t\t\tif (!isMarkedPresentational(current)) {\n\t\t\t\tconst elementTextAlternative = computeElementTextAlternative(current);\n\t\t\t\tif (elementTextAlternative !== null) {\n\t\t\t\t\tconsultedNodes.add(current);\n\t\t\t\t\treturn elementTextAlternative;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// special casing, cheating to make tests pass\n\t\t// https://github.com/w3c/accname/issues/67\n\t\tif (hasAnyConcreteRoles(current, [\"menu\"])) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn \"\";\n\t\t}\n\n\t\t// 2E\n\t\tif (skipToStep2E || context.isEmbeddedInLabel || context.isReferenced) {\n\t\t\tif (hasAnyConcreteRoles(current, [\"combobox\", \"listbox\"])) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\tconst selectedOptions = querySelectedOptions(current);\n\t\t\t\tif (selectedOptions.length === 0) {\n\t\t\t\t\t// defined per test `name_heading_combobox`\n\t\t\t\t\treturn isHTMLInputElement(current) ? current.value : \"\";\n\t\t\t\t}\n\t\t\t\treturn ArrayFrom(selectedOptions)\n\t\t\t\t\t.map((selectedOption) => {\n\t\t\t\t\t\treturn computeTextAlternative(selectedOption, {\n\t\t\t\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\t\t\t\tisReferenced: false,\n\t\t\t\t\t\t\trecursion: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.join(\" \");\n\t\t\t}\n\t\t\tif (hasAbstractRole(current, \"range\")) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\tif (current.hasAttribute(\"aria-valuetext\")) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard\n\t\t\t\t\treturn current.getAttribute(\"aria-valuetext\")!;\n\t\t\t\t}\n\t\t\t\tif (current.hasAttribute(\"aria-valuenow\")) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard\n\t\t\t\t\treturn current.getAttribute(\"aria-valuenow\")!;\n\t\t\t\t}\n\t\t\t\t// Otherwise, use the value as specified by a host language attribute.\n\t\t\t\treturn current.getAttribute(\"value\") || \"\";\n\t\t\t}\n\t\t\tif (hasAnyConcreteRoles(current, [\"textbox\"])) {\n\t\t\t\tconsultedNodes.add(current);\n\t\t\t\treturn getValueOfTextbox(current);\n\t\t\t}\n\t\t}\n\n\t\t// 2F: https://w3c.github.io/accname/#step2F\n\t\tif (\n\t\t\tallowsNameFromContent(current) ||\n\t\t\t(isElement(current) && context.isReferenced) ||\n\t\t\tisNativeHostLanguageTextAlternativeElement(current) ||\n\t\t\tisDescendantOfNativeHostLanguageTextAlternativeElement(current)\n\t\t) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn computeMiscTextAlternative(current, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t}\n\n\t\tif (current.nodeType === current.TEXT_NODE) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn current.textContent || \"\";\n\t\t}\n\n\t\tif (context.recursion) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn computeMiscTextAlternative(current, {\n\t\t\t\tisEmbeddedInLabel: context.isEmbeddedInLabel,\n\t\t\t\tisReferenced: false,\n\t\t\t});\n\t\t}\n\n\t\tconst tooltipAttributeValue = computeTooltipAttributeValue(current);\n\t\tif (tooltipAttributeValue !== null) {\n\t\t\tconsultedNodes.add(current);\n\t\t\treturn tooltipAttributeValue;\n\t\t}\n\n\t\t// TODO should this be reachable?\n\t\tconsultedNodes.add(current);\n\t\treturn \"\";\n\t}\n\n\treturn asFlatString(\n\t\tcomputeTextAlternative(root, {\n\t\t\tisEmbeddedInLabel: false,\n\t\t\t// by spec computeAccessibleDescription starts with the referenced elements as roots\n\t\t\tisReferenced: compute === \"description\",\n\t\t\trecursion: false,\n\t\t})\n\t);\n}\n"],"file":"accessible-name-and-description.js"}