securityos/node_modules/dom-accessibility-api/dist/getRole.mjs.map

1 line
11 KiB
Plaintext
Raw Normal View History

2024-09-06 15:32:35 +00:00
{"version":3,"file":"getRole.mjs","names":["getLocalName","element","localName","tagName","toLowerCase","localNameToRoleMappings","article","aside","button","datalist","dd","details","dialog","dt","fieldset","figure","form","footer","h1","h2","h3","h4","h5","h6","header","hr","html","legend","li","math","main","menu","nav","ol","optgroup","option","output","progress","section","summary","table","tbody","textarea","tfoot","td","th","thead","tr","ul","prohibitedAttributes","caption","Set","code","deletion","emphasis","generic","insertion","paragraph","presentation","strong","subscript","superscript","hasGlobalAriaAttributes","role","some","attributeName","hasAttribute","has","ignorePresentationalRole","implicitRole","getRole","explicitRole","getExplicitRole","getImplicitRole","mappedByTag","undefined","getAttribute","type","size","trim","split","length"],"sources":["../sources/getRole.ts"],"sourcesContent":["// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html\n\n/**\n * Safe Element.localName for all supported environments\n * @param element\n */\nexport function getLocalName(element: Element): string {\n\treturn (\n\t\t// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName\n\t\telement.localName ??\n\t\t// eslint-disable-next-line no-restricted-properties -- required for the fallback\n\t\telement.tagName.toLowerCase()\n\t);\n}\n\nconst localNameToRoleMappings: Record<string, string | undefined> = {\n\tarticle: \"article\",\n\taside: \"complementary\",\n\tbutton: \"button\",\n\tdatalist: \"listbox\",\n\tdd: \"definition\",\n\tdetails: \"group\",\n\tdialog: \"dialog\",\n\tdt: \"term\",\n\tfieldset: \"group\",\n\tfigure: \"figure\",\n\t// WARNING: Only with an accessible name\n\tform: \"form\",\n\tfooter: \"contentinfo\",\n\th1: \"heading\",\n\th2: \"heading\",\n\th3: \"heading\",\n\th4: \"heading\",\n\th5: \"heading\",\n\th6: \"heading\",\n\theader: \"banner\",\n\thr: \"separator\",\n\thtml: \"document\",\n\tlegend: \"legend\",\n\tli: \"listitem\",\n\tmath: \"math\",\n\tmain: \"main\",\n\tmenu: \"list\",\n\tnav: \"navigation\",\n\tol: \"list\",\n\toptgroup: \"group\",\n\t// WARNING: Only in certain context\n\toption: \"option\",\n\toutput: \"status\",\n\tprogress: \"progressbar\",\n\t// WARNING: Only with an accessible name\n\tsection: \"region\",\n\tsummary: \"button\",\n\ttable: \"table\",\n\ttbody: \"rowgroup\",\n\ttextarea: \"textbox\",\n\ttfoot: \"rowgroup\",\n\t// WARNING: Only in certain context\n\ttd: \"cell\",\n\tth: \"columnheader\",\n\tthead: \"rowgroup\",\n\ttr: \"row\",\n\tul: \"list\",\n};\n\nconst prohibitedAttributes: Record<string, Set<string>> = {\n\tcaption: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tcode: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tdeletion: new Set([\"aria-label\", \"aria-labelledby\"]),\n\temphasis: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tgeneric: new Set([\"aria-label\", \"aria-labelledby\", \"aria-roledescription\"]),\n\tinsertion: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tparagraph: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tpresentation: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tstrong: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tsubscript: new Set([\"aria-label\", \"aria-labelledby\"]),\n\tsuperscript: new Set([\"aria-label\", \"aria-labelledby\"]),\n};\n\n/**\n *\n * @param element\n * @param role The role used for this element. This is specified to control whether you want to use the implicit or explicit role.\n */\nfunction hasGlobalAriaAttributes(element: Element, role: string): boolean {\n\t// https://rawgit.com/w3c/aria/stable/#global_states\n\t// commented attributes are deprecated\n\treturn [\n\t\t\"aria-atomic\",\n\t\t\"aria-busy\",\n\t\t\"aria-controls\",\n\t\t\"aria-current\",\n\t\t\"aria-describedby\",\n\t\t\"aria-details\",\n\t\t// \"disabled\",\n\t\t\"aria-dropeffect\",\n\t\t// \"errormessage\",\n\t\t\"aria-flowto\",\n\t\t\"aria-grabbed\",\n\t\t// \"haspopup\",\n\t\t\"aria-hidden\",\n\t\t// \"invalid\",\n\t\