1 |
- {"ast":null,"code":"// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html\nimport { getLocalName } from \"./util.mjs\";\nvar localNameToRoleMappings = {\n article: \"article\",\n aside: \"complementary\",\n body: \"document\",\n button: \"button\",\n datalist: \"listbox\",\n dd: \"definition\",\n details: \"group\",\n dialog: \"dialog\",\n dt: \"term\",\n fieldset: \"group\",\n figure: \"figure\",\n // WARNING: Only with an accessible name\n form: \"form\",\n footer: \"contentinfo\",\n h1: \"heading\",\n h2: \"heading\",\n h3: \"heading\",\n h4: \"heading\",\n h5: \"heading\",\n h6: \"heading\",\n header: \"banner\",\n hr: \"separator\",\n legend: \"legend\",\n li: \"listitem\",\n math: \"math\",\n main: \"main\",\n menu: \"list\",\n nav: \"navigation\",\n ol: \"list\",\n optgroup: \"group\",\n // WARNING: Only in certain context\n option: \"option\",\n output: \"status\",\n progress: \"progressbar\",\n // WARNING: Only with an accessible name\n section: \"region\",\n summary: \"button\",\n table: \"table\",\n tbody: \"rowgroup\",\n textarea: \"textbox\",\n tfoot: \"rowgroup\",\n // WARNING: Only in certain context\n td: \"cell\",\n th: \"columnheader\",\n thead: \"rowgroup\",\n tr: \"row\",\n ul: \"list\"\n};\nvar prohibitedAttributes = {\n caption: new Set([\"aria-label\", \"aria-labelledby\"]),\n code: new Set([\"aria-label\", \"aria-labelledby\"]),\n deletion: new Set([\"aria-label\", \"aria-labelledby\"]),\n emphasis: new Set([\"aria-label\", \"aria-labelledby\"]),\n generic: new Set([\"aria-label\", \"aria-labelledby\", \"aria-roledescription\"]),\n insertion: new Set([\"aria-label\", \"aria-labelledby\"]),\n paragraph: new Set([\"aria-label\", \"aria-labelledby\"]),\n presentation: new Set([\"aria-label\", \"aria-labelledby\"]),\n strong: new Set([\"aria-label\", \"aria-labelledby\"]),\n subscript: new Set([\"aria-label\", \"aria-labelledby\"]),\n superscript: new Set([\"aria-label\", \"aria-labelledby\"])\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 */\n\nfunction hasGlobalAriaAttributes(element, role) {\n // https://rawgit.com/w3c/aria/stable/#global_states\n // commented attributes are deprecated\n return [\"aria-atomic\", \"aria-busy\", \"aria-controls\", \"aria-current\", \"aria-describedby\", \"aria-details\", // \"disabled\",\n \"aria-dropeffect\", // \"errormessage\",\n \"aria-flowto\", \"aria-grabbed\", // \"haspopup\",\n \"aria-hidden\", // \"invalid\",\n \"aria-keyshortcuts\", \"aria-label\", \"aria-labelledby\", \"aria-live\", \"aria-owns\", \"aria-relevant\", \"aria-roledescription\"].some(function (attributeName) {\n var _prohibitedAttributes;\n\n return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) !== null && _prohibitedAttributes !== void 0 && _prohibitedAttributes.has(attributeName));\n });\n}\n\nfunction ignorePresentationalRole(element, implicitRole) {\n // https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none\n return hasGlobalAriaAttributes(element, implicitRole);\n}\n\nexport default function getRole(element) {\n var explicitRole = getExplicitRole(element);\n\n if (explicitRole === null || explicitRole === \"presentation\") {\n var implicitRole = getImplicitRole(element);\n\n if (explicitRole !== \"presentation\" || ignorePresentationalRole(element, implicitRole || \"\")) {\n return implicitRole;\n }\n }\n\n return explicitRole;\n}\n\nfunction getImplicitRole(element) {\n var mappedByTag = localNameToRoleMappings[getLocalName(element)];\n\n if (mappedByTag !== undefined) {\n return mappedByTag;\n }\n\n switch (getLocalName(element)) {\n case \"a\":\n case \"area\":\n case \"link\":\n if (element.hasAttribute(\"href\")) {\n return \"link\";\n }\n\n break;\n\n case \"img\":\n if (element.getAttribute(\"alt\") === \"\" && !ignorePresentationalRole(element, \"img\")) {\n return \"presentation\";\n }\n\n return \"img\";\n\n case \"input\":\n {\n var _ref = element,\n type = _ref.type;\n\n switch (type) {\n case \"button\":\n case \"image\":\n case \"reset\":\n case \"submit\":\n return \"button\";\n\n case \"checkbox\":\n case \"radio\":\n return type;\n\n case \"range\":\n return \"slider\";\n\n case \"email\":\n case \"tel\":\n case \"text\":\n case \"url\":\n if (element.hasAttribute(\"list\")) {\n return \"combobox\";\n }\n\n return \"textbox\";\n\n case \"search\":\n if (element.hasAttribute(\"list\")) {\n return \"combobox\";\n }\n\n return \"searchbox\";\n\n default:\n return null;\n }\n }\n\n case \"select\":\n if (element.hasAttribute(\"multiple\") || element.size > 1) {\n return \"listbox\";\n }\n\n return \"combobox\";\n }\n\n return null;\n}\n\nfunction getExplicitRole(element) {\n var role = element.getAttribute(\"role\");\n\n if (role !== null) {\n var explicitRole = role.trim().split(\" \")[0]; // String.prototype.split(sep, limit) will always return an array with at least one member\n // as long as limit is either undefined or > 0\n\n if (explicitRole.length > 0) {\n return explicitRole;\n }\n }\n\n return null;\n}","map":{"version":3,"sources":["../sources/getRole.ts"],"names":["localNameToRoleMappings","article","aside","body","button","datalist","dd","details","dialog","dt","fieldset","figure","form","footer","h1","h2","h3","h4","h5","h6","header","hr","legend","li","math","main","menu","nav","ol","optgroup","option","output","progress","section","summary","table","tbody","textarea","tfoot","td","th","thead","tr","ul","prohibitedAttributes","caption","code","deletion","emphasis","generic","insertion","paragraph","presentation","strong","subscript","superscript","element","hasGlobalAriaAttributes","explicitRole","getExplicitRole","implicitRole","getImplicitRole","ignorePresentationalRole","mappedByTag","getLocalName","type","role"],"mappings":"AAAA;AAEA,SAAA,YAAA,QAAA,YAAA;AAEA,IAAMA,uBAA2D,GAAG;AACnEC,EAAAA,OAAO,EAD4D,SAAA;AAEnEC,EAAAA,KAAK,EAF8D,eAAA;AAGnEC,EAAAA,IAAI,EAH+D,UAAA;AAInEC,EAAAA,MAAM,EAJ6D,QAAA;AAKnEC,EAAAA,QAAQ,EAL2D,SAAA;AAMnEC,EAAAA,EAAE,EANiE,YAAA;AAOnEC,EAAAA,OAAO,EAP4D,OAAA;AAQnEC,EAAAA,MAAM,EAR6D,QAAA;AASnEC,EAAAA,EAAE,EATiE,MAAA;AAUnEC,EAAAA,QAAQ,EAV2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CAElB;AACA;;AACA,QAAIR,YAAY,CAAZA,MAAAA,GAAJ,CAAA,EAA6B;AAC5B,aAAA,YAAA;AACA;AACD;;AAED,SAAA,IAAA;AACA","sourcesContent":["// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html\n\nimport { getLocalName } from \"./util\";\n\nconst localNameToRoleMappings: Record<string, string | undefined> = {\n\tarticle: \"article\",\n\taside: \"complementary\",\n\tbody: \"document\",\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\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\t\"aria-keyshortcuts\",\n\t\t\"aria-label\",\n\t\t\"aria-labelledby\",\n\t\t\"aria-live\",\n\t\t\"aria-owns\",\n\t\t\"aria-relevant\",\n\t\t\"aria-roledescription\",\n\t].some((attributeName) => {\n\t\treturn (\n\t\t\telement.hasAttribute(attributeName) &&\n\t\t\t!prohibitedAttributes[role]?.has(attributeName)\n\t\t);\n\t});\n}\n\nfunction ignorePresentationalRole(\n\telement: Element,\n\timplicitRole: string\n): boolean {\n\t// https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none\n\treturn hasGlobalAriaAttributes(element, implicitRole);\n}\n\nexport default function getRole(element: Element): string | null {\n\tconst explicitRole = getExplicitRole(element);\n\tif (explicitRole === null || explicitRole === \"presentation\") {\n\t\tconst implicitRole = getImplicitRole(element);\n\t\tif (\n\t\t\texplicitRole !== \"presentation\" ||\n\t\t\tignorePresentationalRole(element, implicitRole || \"\")\n\t\t) {\n\t\t\treturn implicitRole;\n\t\t}\n\t}\n\n\treturn explicitRole;\n}\n\nfunction getImplicitRole(element: Element): string | null {\n\tconst mappedByTag = localNameToRoleMappings[getLocalName(element)];\n\tif (mappedByTag !== undefined) {\n\t\treturn mappedByTag;\n\t}\n\n\tswitch (getLocalName(element)) {\n\t\tcase \"a\":\n\t\tcase \"area\":\n\t\tcase \"link\":\n\t\t\tif (element.hasAttribute(\"href\")) {\n\t\t\t\treturn \"link\";\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"img\":\n\t\t\tif (\n\t\t\t\telement.getAttribute(\"alt\") === \"\" &&\n\t\t\t\t!ignorePresentationalRole(element, \"img\")\n\t\t\t) {\n\t\t\t\treturn \"presentation\";\n\t\t\t}\n\t\t\treturn \"img\";\n\t\tcase \"input\": {\n\t\t\tconst { type } = element as HTMLInputElement;\n\t\t\tswitch (type) {\n\t\t\t\tcase \"button\":\n\t\t\t\tcase \"image\":\n\t\t\t\tcase \"reset\":\n\t\t\t\tcase \"submit\":\n\t\t\t\t\treturn \"button\";\n\t\t\t\tcase \"checkbox\":\n\t\t\t\tcase \"radio\":\n\t\t\t\t\treturn type;\n\t\t\t\tcase \"range\":\n\t\t\t\t\treturn \"slider\";\n\t\t\t\tcase \"email\":\n\t\t\t\tcase \"tel\":\n\t\t\t\tcase \"text\":\n\t\t\t\tcase \"url\":\n\t\t\t\t\tif (element.hasAttribute(\"list\")) {\n\t\t\t\t\t\treturn \"combobox\";\n\t\t\t\t\t}\n\t\t\t\t\treturn \"textbox\";\n\n\t\t\t\tcase \"search\":\n\t\t\t\t\tif (element.hasAttribute(\"list\")) {\n\t\t\t\t\t\treturn \"combobox\";\n\t\t\t\t\t}\n\t\t\t\t\treturn \"searchbox\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tcase \"select\":\n\t\t\tif (\n\t\t\t\telement.hasAttribute(\"multiple\") ||\n\t\t\t\t(element as HTMLSelectElement).size > 1\n\t\t\t) {\n\t\t\t\treturn \"listbox\";\n\t\t\t}\n\t\t\treturn \"combobox\";\n\t}\n\treturn null;\n}\n\nfunction getExplicitRole(element: Element): string | null {\n\tconst role = element.getAttribute(\"role\");\n\tif (role !== null) {\n\t\tconst explicitRole = role.trim().split(\" \")[0];\n\t\t// String.prototype.split(sep, limit) will always return an array with at least one member\n\t\t// as long as limit is either undefined or > 0\n\t\tif (explicitRole.length > 0) {\n\t\t\treturn explicitRole;\n\t\t}\n\t}\n\n\treturn null;\n}\n"]},"metadata":{},"sourceType":"module"}
|