0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

View file

@ -0,0 +1,9 @@
import { ComputeTextAlternativeOptions } from "./accessible-name-and-description";
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_description
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export declare function computeAccessibleDescription(root: Element, options?: ComputeTextAlternativeOptions): string;
//# sourceMappingURL=accessible-description.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"accessible-description.d.ts","sourceRoot":"","sources":["../sources/accessible-description.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,6BAA6B,EAC7B,MAAM,mCAAmC,CAAC;AAG3C;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,6BAAkC,GACzC,MAAM,CAqBR"}

View file

@ -0,0 +1,41 @@
"use strict";
exports.__esModule = true;
exports.computeAccessibleDescription = computeAccessibleDescription;
var _accessibleNameAndDescription = require("./accessible-name-and-description");
var _util = require("./util");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_description
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
function computeAccessibleDescription(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var description = (0, _util.queryIdRefs)(root, "aria-describedby").map(function (element) {
return (0, _accessibleNameAndDescription.computeTextAlternative)(element, _objectSpread(_objectSpread({}, options), {}, {
compute: "description"
}));
}).join(" "); // TODO: Technically we need to make sure that node wasn't used for the accessible name
// This causes `description_1.0_combobox-focusable-manual` to fail
//
// https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation
// says for so many elements to use the `title` that we assume all elements are considered
if (description === "") {
var title = root.getAttribute("title");
description = title === null ? "" : title;
}
return description;
}
//# sourceMappingURL=accessible-description.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../sources/accessible-description.ts"],"names":["computeAccessibleDescription","root","options","description","map","element","compute","join","title","getAttribute"],"mappings":";;;;;AAAA;;AAIA;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,4BAAT,CACNC,IADM,EAGG;AAAA,MADTC,OACS,uEADgC,EAChC;AACT,MAAIC,WAAW,GAAG,uBAAYF,IAAZ,EAAkB,kBAAlB,EAChBG,GADgB,CACZ,UAACC,OAAD,EAAa;AACjB,WAAO,0DAAuBA,OAAvB,kCACHH,OADG;AAENI,MAAAA,OAAO,EAAE;AAFH,OAAP;AAIA,GANgB,EAOhBC,IAPgB,CAOX,GAPW,CAAlB,CADS,CAUT;AACA;AACA;AACA;AACA;;AACA,MAAIJ,WAAW,KAAK,EAApB,EAAwB;AACvB,QAAMK,KAAK,GAAGP,IAAI,CAACQ,YAAL,CAAkB,OAAlB,CAAd;AACAN,IAAAA,WAAW,GAAGK,KAAK,KAAK,IAAV,GAAiB,EAAjB,GAAsBA,KAApC;AACA;;AAED,SAAOL,WAAP;AACA","sourcesContent":["import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { queryIdRefs } from \"./util\";\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_description\n * @param root\n * @param [options]\n * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n */\nexport function computeAccessibleDescription(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tlet description = queryIdRefs(root, \"aria-describedby\")\n\t\t.map((element) => {\n\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t...options,\n\t\t\t\tcompute: \"description\",\n\t\t\t});\n\t\t})\n\t\t.join(\" \");\n\n\t// TODO: Technically we need to make sure that node wasn't used for the accessible name\n\t// This causes `description_1.0_combobox-focusable-manual` to fail\n\t//\n\t// https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation\n\t// says for so many elements to use the `title` that we assume all elements are considered\n\tif (description === \"\") {\n\t\tconst title = root.getAttribute(\"title\");\n\t\tdescription = title === null ? \"\" : title;\n\t}\n\n\treturn description;\n}\n"],"file":"accessible-description.js"}

View file

@ -0,0 +1,35 @@
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { computeTextAlternative } from "./accessible-name-and-description.mjs";
import { queryIdRefs } from "./util.mjs";
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_description
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export function computeAccessibleDescription(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var description = queryIdRefs(root, "aria-describedby").map(function (element) {
return computeTextAlternative(element, _objectSpread(_objectSpread({}, options), {}, {
compute: "description"
}));
}).join(" "); // TODO: Technically we need to make sure that node wasn't used for the accessible name
// This causes `description_1.0_combobox-focusable-manual` to fail
//
// https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation
// says for so many elements to use the `title` that we assume all elements are considered
if (description === "") {
var title = root.getAttribute("title");
description = title === null ? "" : title;
}
return description;
}
//# sourceMappingURL=accessible-description.mjs.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../sources/accessible-description.ts"],"names":["computeTextAlternative","queryIdRefs","computeAccessibleDescription","root","options","description","map","element","compute","join","title","getAttribute"],"mappings":";;;;;;AAAA,SACCA,sBADD,QAGO,uCAHP;AAIA,SAASC,WAAT,QAA4B,YAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,4BAAT,CACNC,IADM,EAGG;AAAA,MADTC,OACS,uEADgC,EAChC;AACT,MAAIC,WAAW,GAAGJ,WAAW,CAACE,IAAD,EAAO,kBAAP,CAAX,CAChBG,GADgB,CACZ,UAACC,OAAD,EAAa;AACjB,WAAOP,sBAAsB,CAACO,OAAD,kCACzBH,OADyB;AAE5BI,MAAAA,OAAO,EAAE;AAFmB,OAA7B;AAIA,GANgB,EAOhBC,IAPgB,CAOX,GAPW,CAAlB,CADS,CAUT;AACA;AACA;AACA;AACA;;AACA,MAAIJ,WAAW,KAAK,EAApB,EAAwB;AACvB,QAAMK,KAAK,GAAGP,IAAI,CAACQ,YAAL,CAAkB,OAAlB,CAAd;AACAN,IAAAA,WAAW,GAAGK,KAAK,KAAK,IAAV,GAAiB,EAAjB,GAAsBA,KAApC;AACA;;AAED,SAAOL,WAAP;AACA","sourcesContent":["import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { queryIdRefs } from \"./util\";\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_description\n * @param root\n * @param [options]\n * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n */\nexport function computeAccessibleDescription(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tlet description = queryIdRefs(root, \"aria-describedby\")\n\t\t.map((element) => {\n\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t...options,\n\t\t\t\tcompute: \"description\",\n\t\t\t});\n\t\t})\n\t\t.join(\" \");\n\n\t// TODO: Technically we need to make sure that node wasn't used for the accessible name\n\t// This causes `description_1.0_combobox-focusable-manual` to fail\n\t//\n\t// https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation\n\t// says for so many elements to use the `title` that we assume all elements are considered\n\tif (description === \"\") {\n\t\tconst title = root.getAttribute(\"title\");\n\t\tdescription = title === null ? \"\" : title;\n\t}\n\n\treturn description;\n}\n"],"file":"accessible-description.mjs"}

View file

@ -0,0 +1,20 @@
/**
* interface for an options-bag where `window.getComputedStyle` can be mocked
*/
export interface ComputeTextAlternativeOptions {
compute?: "description" | "name";
/**
* Set to true if window.computedStyle supports the second argument.
* This should be false in JSDOM. Otherwise JSDOM will log console errors.
*/
computedStyleSupportsPseudoElements?: boolean;
getComputedStyle?: typeof window.getComputedStyle;
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_te
* @param root
* @param [options]
* @param [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export declare function computeTextAlternative(root: Element, options?: ComputeTextAlternativeOptions): string;
//# sourceMappingURL=accessible-name-and-description.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"accessible-name-and-description.d.ts","sourceRoot":"","sources":["../sources/accessible-name-and-description.ts"],"names":[],"mappings":"AA+BA;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC7C,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IACjC;;;OAGG;IACH,mCAAmC,CAAC,EAAE,OAAO,CAAC;IAC9C,gBAAgB,CAAC,EAAE,OAAO,MAAM,CAAC,gBAAgB,CAAC;CAClD;AA6RD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,6BAAkC,GACzC,MAAM,CAgWR"}

View file

@ -0,0 +1,599 @@
"use strict";
exports.__esModule = true;
exports.computeTextAlternative = computeTextAlternative;
var _array = _interopRequireDefault(require("./polyfills/array.from"));
var _SetLike = _interopRequireDefault(require("./polyfills/SetLike"));
var _util = require("./util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* implements https://w3c.github.io/accname/
*/
/**
*
* @param {string} string -
* @returns {FlatString} -
*/
function asFlatString(s) {
return s.trim().replace(/\s\s+/g, " ");
}
/**
*
* @param node -
* @param options - These are not optional to prevent accidentally calling it without options in `computeAccessibleName`
* @returns {boolean} -
*/
function isHidden(node, getComputedStyleImplementation) {
if (!(0, _util.isElement)(node)) {
return false;
}
if (node.hasAttribute("hidden") || node.getAttribute("aria-hidden") === "true") {
return true;
}
var style = getComputedStyleImplementation(node);
return style.getPropertyValue("display") === "none" || style.getPropertyValue("visibility") === "hidden";
}
/**
* @param {Node} node -
* @returns {boolean} - As defined in step 2E of https://w3c.github.io/accname/#mapping_additional_nd_te
*/
function isControl(node) {
return (0, _util.hasAnyConcreteRoles)(node, ["button", "combobox", "listbox", "textbox"]) || hasAbstractRole(node, "range");
}
function hasAbstractRole(node, role) {
if (!(0, _util.isElement)(node)) {
return false;
}
switch (role) {
case "range":
return (0, _util.hasAnyConcreteRoles)(node, ["meter", "progressbar", "scrollbar", "slider", "spinbutton"]);
default:
throw new TypeError("No knowledge about abstract role '".concat(role, "'. This is likely a bug :("));
}
}
/**
* element.querySelectorAll but also considers owned tree
* @param element
* @param selectors
*/
function querySelectorAllSubtree(element, selectors) {
var elements = (0, _array.default)(element.querySelectorAll(selectors));
(0, _util.queryIdRefs)(element, "aria-owns").forEach(function (root) {
// babel transpiles this assuming an iterator
elements.push.apply(elements, (0, _array.default)(root.querySelectorAll(selectors)));
});
return elements;
}
function querySelectedOptions(listbox) {
if ((0, _util.isHTMLSelectElement)(listbox)) {
// IE11 polyfill
return listbox.selectedOptions || querySelectorAllSubtree(listbox, "[selected]");
}
return querySelectorAllSubtree(listbox, '[aria-selected="true"]');
}
function isMarkedPresentational(node) {
return (0, _util.hasAnyConcreteRoles)(node, ["none", "presentation"]);
}
/**
* Elements specifically listed in html-aam
*
* We don't need this for `label` or `legend` elements.
* Their implicit roles already allow "naming from content".
*
* sources:
*
* - https://w3c.github.io/html-aam/#table-element
*/
function isNativeHostLanguageTextAlternativeElement(node) {
return (0, _util.isHTMLTableCaptionElement)(node);
}
/**
* https://w3c.github.io/aria/#namefromcontent
*/
function allowsNameFromContent(node) {
return (0, _util.hasAnyConcreteRoles)(node, ["button", "cell", "checkbox", "columnheader", "gridcell", "heading", "label", "legend", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "row", "rowheader", "switch", "tab", "tooltip", "treeitem"]);
}
/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/100
*/
function isDescendantOfNativeHostLanguageTextAlternativeElement( // eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
node) {
return false;
}
/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/101
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
function computeTooltipAttributeValue(node) {
return null;
}
function getValueOfTextbox(element) {
if ((0, _util.isHTMLInputElement)(element) || (0, _util.isHTMLTextAreaElement)(element)) {
return element.value;
} // https://github.com/eps1lon/dom-accessibility-api/issues/4
return element.textContent || "";
}
function getTextualContent(declaration) {
var content = declaration.getPropertyValue("content");
if (/^["'].*["']$/.test(content)) {
return content.slice(1, -1);
}
return "";
}
/**
* https://html.spec.whatwg.org/multipage/forms.html#category-label
* TODO: form-associated custom elements
* @param element
*/
function isLabelableElement(element) {
var localName = (0, _util.getLocalName)(element);
return localName === "button" || localName === "input" && element.getAttribute("type") !== "hidden" || localName === "meter" || localName === "output" || localName === "progress" || localName === "select" || localName === "textarea";
}
/**
* > [...], then the first such descendant in tree order is the label element's labeled control.
* -- https://html.spec.whatwg.org/multipage/forms.html#labeled-control
* @param element
*/
function findLabelableElement(element) {
if (isLabelableElement(element)) {
return element;
}
var labelableElement = null;
element.childNodes.forEach(function (childNode) {
if (labelableElement === null && (0, _util.isElement)(childNode)) {
var descendantLabelableElement = findLabelableElement(childNode);
if (descendantLabelableElement !== null) {
labelableElement = descendantLabelableElement;
}
}
});
return labelableElement;
}
/**
* Polyfill of HTMLLabelElement.control
* https://html.spec.whatwg.org/multipage/forms.html#labeled-control
* @param label
*/
function getControlOfLabel(label) {
if (label.control !== undefined) {
return label.control;
}
var htmlFor = label.getAttribute("for");
if (htmlFor !== null) {
return label.ownerDocument.getElementById(htmlFor);
}
return findLabelableElement(label);
}
/**
* Polyfill of HTMLInputElement.labels
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels
* @param element
*/
function getLabels(element) {
var labelsProperty = element.labels;
if (labelsProperty === null) {
return labelsProperty;
}
if (labelsProperty !== undefined) {
return (0, _array.default)(labelsProperty);
} // polyfill
if (!isLabelableElement(element)) {
return null;
}
var document = element.ownerDocument;
return (0, _array.default)(document.querySelectorAll("label")).filter(function (label) {
return getControlOfLabel(label) === element;
});
}
/**
* Gets the contents of a slot used for computing the accname
* @param slot
*/
function getSlotContents(slot) {
// Computing the accessible name for elements containing slots is not
// currently defined in the spec. This implementation reflects the
// behavior of NVDA 2020.2/Firefox 81 and iOS VoiceOver/Safari 13.6.
var assignedNodes = slot.assignedNodes();
if (assignedNodes.length === 0) {
// if no nodes are assigned to the slot, it displays the default content
return (0, _array.default)(slot.childNodes);
}
return assignedNodes;
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_te
* @param root
* @param [options]
* @param [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
function computeTextAlternative(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var consultedNodes = new _SetLike.default();
var window = (0, _util.safeWindow)(root);
var _options$compute = options.compute,
compute = _options$compute === void 0 ? "name" : _options$compute,
_options$computedStyl = options.computedStyleSupportsPseudoElements,
computedStyleSupportsPseudoElements = _options$computedStyl === void 0 ? options.getComputedStyle !== undefined : _options$computedStyl,
_options$getComputedS = options.getComputedStyle,
getComputedStyle = _options$getComputedS === void 0 ? window.getComputedStyle.bind(window) : _options$getComputedS; // 2F.i
function computeMiscTextAlternative(node, context) {
var accumulatedText = "";
if ((0, _util.isElement)(node) && computedStyleSupportsPseudoElements) {
var pseudoBefore = getComputedStyle(node, "::before");
var beforeContent = getTextualContent(pseudoBefore);
accumulatedText = "".concat(beforeContent, " ").concat(accumulatedText);
} // FIXME: Including aria-owns is not defined in the spec
// But it is required in the web-platform-test
var childNodes = (0, _util.isHTMLSlotElement)(node) ? getSlotContents(node) : (0, _array.default)(node.childNodes).concat((0, _util.queryIdRefs)(node, "aria-owns"));
childNodes.forEach(function (child) {
var result = computeTextAlternative(child, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
}); // TODO: Unclear why display affects delimiter
// see https://github.com/w3c/accname/issues/3
var display = (0, _util.isElement)(child) ? getComputedStyle(child).getPropertyValue("display") : "inline";
var separator = display !== "inline" ? " " : ""; // trailing separator for wpt tests
accumulatedText += "".concat(separator).concat(result).concat(separator);
});
if ((0, _util.isElement)(node) && computedStyleSupportsPseudoElements) {
var pseudoAfter = getComputedStyle(node, "::after");
var afterContent = getTextualContent(pseudoAfter);
accumulatedText = "".concat(accumulatedText, " ").concat(afterContent);
}
return accumulatedText;
}
function computeElementTextAlternative(node) {
if (!(0, _util.isElement)(node)) {
return null;
}
/**
*
* @param element
* @param attributeName
* @returns A string non-empty string or `null`
*/
function useAttribute(element, attributeName) {
var attribute = element.getAttributeNode(attributeName);
if (attribute !== null && !consultedNodes.has(attribute) && attribute.value.trim() !== "") {
consultedNodes.add(attribute);
return attribute.value;
}
return null;
} // https://w3c.github.io/html-aam/#fieldset-and-legend-elements
if ((0, _util.isHTMLFieldSetElement)(node)) {
consultedNodes.add(node);
var children = (0, _array.default)(node.childNodes);
for (var i = 0; i < children.length; i += 1) {
var child = children[i];
if ((0, _util.isHTMLLegendElement)(child)) {
return computeTextAlternative(child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
} else if ((0, _util.isHTMLTableElement)(node)) {
// https://w3c.github.io/html-aam/#table-element
consultedNodes.add(node);
var _children = (0, _array.default)(node.childNodes);
for (var _i = 0; _i < _children.length; _i += 1) {
var _child = _children[_i];
if ((0, _util.isHTMLTableCaptionElement)(_child)) {
return computeTextAlternative(_child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
} else if ((0, _util.isSVGSVGElement)(node)) {
// https://www.w3.org/TR/svg-aam-1.0/
consultedNodes.add(node);
var _children2 = (0, _array.default)(node.childNodes);
for (var _i2 = 0; _i2 < _children2.length; _i2 += 1) {
var _child2 = _children2[_i2];
if ((0, _util.isSVGTitleElement)(_child2)) {
return _child2.textContent;
}
}
return null;
} else if ((0, _util.getLocalName)(node) === "img" || (0, _util.getLocalName)(node) === "area") {
// https://w3c.github.io/html-aam/#area-element
// https://w3c.github.io/html-aam/#img-element
var nameFromAlt = useAttribute(node, "alt");
if (nameFromAlt !== null) {
return nameFromAlt;
}
} else if ((0, _util.isHTMLOptGroupElement)(node)) {
var nameFromLabel = useAttribute(node, "label");
if (nameFromLabel !== null) {
return nameFromLabel;
}
}
if ((0, _util.isHTMLInputElement)(node) && (node.type === "button" || node.type === "submit" || node.type === "reset")) {
// 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
var nameFromValue = useAttribute(node, "value");
if (nameFromValue !== null) {
return nameFromValue;
} // TODO: l10n
if (node.type === "submit") {
return "Submit";
} // TODO: l10n
if (node.type === "reset") {
return "Reset";
}
}
var labels = getLabels(node);
if (labels !== null && labels.length !== 0) {
consultedNodes.add(node);
return (0, _array.default)(labels).map(function (element) {
return computeTextAlternative(element, {
isEmbeddedInLabel: true,
isReferenced: false,
recursion: true
});
}).filter(function (label) {
return label.length > 0;
}).join(" ");
} // https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation
// TODO: wpt test consider label elements but html-aam does not mention them
// We follow existing implementations over spec
if ((0, _util.isHTMLInputElement)(node) && node.type === "image") {
var _nameFromAlt = useAttribute(node, "alt");
if (_nameFromAlt !== null) {
return _nameFromAlt;
}
var nameFromTitle = useAttribute(node, "title");
if (nameFromTitle !== null) {
return nameFromTitle;
} // TODO: l10n
return "Submit Query";
}
return useAttribute(node, "title");
}
function computeTextAlternative(current, context) {
if (consultedNodes.has(current)) {
return "";
} // special casing, cheating to make tests pass
// https://github.com/w3c/accname/issues/67
if ((0, _util.hasAnyConcreteRoles)(current, ["menu"])) {
consultedNodes.add(current);
return "";
} // 2A
if (isHidden(current, getComputedStyle) && !context.isReferenced) {
consultedNodes.add(current);
return "";
} // 2B
var labelElements = (0, _util.queryIdRefs)(current, "aria-labelledby");
if (compute === "name" && !context.isReferenced && labelElements.length > 0) {
return labelElements.map(function (element) {
return computeTextAlternative(element, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: true,
// thais isn't recursion as specified, otherwise we would skip
// `aria-label` in
// <input id="myself" aria-label="foo" aria-labelledby="myself"
recursion: false
});
}).join(" ");
} // 2C
// Changed from the spec in anticipation of https://github.com/w3c/accname/issues/64
// spec says we should only consider skipping if we have a non-empty label
var skipToStep2E = context.recursion && isControl(current) && compute === "name";
if (!skipToStep2E) {
var ariaLabel = ((0, _util.isElement)(current) && current.getAttribute("aria-label") || "").trim();
if (ariaLabel !== "" && compute === "name") {
consultedNodes.add(current);
return ariaLabel;
} // 2D
if (!isMarkedPresentational(current)) {
var elementTextAlternative = computeElementTextAlternative(current);
if (elementTextAlternative !== null) {
consultedNodes.add(current);
return elementTextAlternative;
}
}
} // 2E
if (skipToStep2E || context.isEmbeddedInLabel || context.isReferenced) {
if ((0, _util.hasAnyConcreteRoles)(current, ["combobox", "listbox"])) {
consultedNodes.add(current);
var selectedOptions = querySelectedOptions(current);
if (selectedOptions.length === 0) {
// defined per test `name_heading_combobox`
return (0, _util.isHTMLInputElement)(current) ? current.value : "";
}
return (0, _array.default)(selectedOptions).map(function (selectedOption) {
return computeTextAlternative(selectedOption, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
});
}).join(" ");
}
if (hasAbstractRole(current, "range")) {
consultedNodes.add(current);
if (current.hasAttribute("aria-valuetext")) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard
return current.getAttribute("aria-valuetext");
}
if (current.hasAttribute("aria-valuenow")) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard
return current.getAttribute("aria-valuenow");
} // Otherwise, use the value as specified by a host language attribute.
return current.getAttribute("value") || "";
}
if ((0, _util.hasAnyConcreteRoles)(current, ["textbox"])) {
consultedNodes.add(current);
return getValueOfTextbox(current);
}
} // 2F: https://w3c.github.io/accname/#step2F
if (allowsNameFromContent(current) || (0, _util.isElement)(current) && context.isReferenced || isNativeHostLanguageTextAlternativeElement(current) || isDescendantOfNativeHostLanguageTextAlternativeElement(current)) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false
});
}
if (current.nodeType === current.TEXT_NODE) {
consultedNodes.add(current);
return current.textContent || "";
}
if (context.recursion) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false
});
}
var tooltipAttributeValue = computeTooltipAttributeValue(current);
if (tooltipAttributeValue !== null) {
consultedNodes.add(current);
return tooltipAttributeValue;
} // TODO should this be reachable?
consultedNodes.add(current);
return "";
}
return asFlatString(computeTextAlternative(root, {
isEmbeddedInLabel: false,
// by spec computeAccessibleDescription starts with the referenced elements as roots
isReferenced: compute === "description",
recursion: false
}));
}
//# sourceMappingURL=accessible-name-and-description.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,592 @@
/**
* implements https://w3c.github.io/accname/
*/
import ArrayFrom from "./polyfills/array.from.mjs";
import SetLike from "./polyfills/SetLike.mjs";
import { hasAnyConcreteRoles, isElement, isHTMLTableCaptionElement, isHTMLInputElement, isHTMLSelectElement, isHTMLTextAreaElement, safeWindow, isHTMLFieldSetElement, isHTMLLegendElement, isHTMLOptGroupElement, isHTMLTableElement, isHTMLSlotElement, isSVGSVGElement, isSVGTitleElement, queryIdRefs, getLocalName } from "./util.mjs";
/**
* 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.
*/
/**
*
* @param {string} string -
* @returns {FlatString} -
*/
function asFlatString(s) {
return s.trim().replace(/\s\s+/g, " ");
}
/**
*
* @param node -
* @param options - These are not optional to prevent accidentally calling it without options in `computeAccessibleName`
* @returns {boolean} -
*/
function isHidden(node, getComputedStyleImplementation) {
if (!isElement(node)) {
return false;
}
if (node.hasAttribute("hidden") || node.getAttribute("aria-hidden") === "true") {
return true;
}
var style = getComputedStyleImplementation(node);
return style.getPropertyValue("display") === "none" || style.getPropertyValue("visibility") === "hidden";
}
/**
* @param {Node} node -
* @returns {boolean} - As defined in step 2E of https://w3c.github.io/accname/#mapping_additional_nd_te
*/
function isControl(node) {
return hasAnyConcreteRoles(node, ["button", "combobox", "listbox", "textbox"]) || hasAbstractRole(node, "range");
}
function hasAbstractRole(node, role) {
if (!isElement(node)) {
return false;
}
switch (role) {
case "range":
return hasAnyConcreteRoles(node, ["meter", "progressbar", "scrollbar", "slider", "spinbutton"]);
default:
throw new TypeError("No knowledge about abstract role '".concat(role, "'. This is likely a bug :("));
}
}
/**
* element.querySelectorAll but also considers owned tree
* @param element
* @param selectors
*/
function querySelectorAllSubtree(element, selectors) {
var elements = ArrayFrom(element.querySelectorAll(selectors));
queryIdRefs(element, "aria-owns").forEach(function (root) {
// babel transpiles this assuming an iterator
elements.push.apply(elements, ArrayFrom(root.querySelectorAll(selectors)));
});
return elements;
}
function querySelectedOptions(listbox) {
if (isHTMLSelectElement(listbox)) {
// IE11 polyfill
return listbox.selectedOptions || querySelectorAllSubtree(listbox, "[selected]");
}
return querySelectorAllSubtree(listbox, '[aria-selected="true"]');
}
function isMarkedPresentational(node) {
return hasAnyConcreteRoles(node, ["none", "presentation"]);
}
/**
* Elements specifically listed in html-aam
*
* We don't need this for `label` or `legend` elements.
* Their implicit roles already allow "naming from content".
*
* sources:
*
* - https://w3c.github.io/html-aam/#table-element
*/
function isNativeHostLanguageTextAlternativeElement(node) {
return isHTMLTableCaptionElement(node);
}
/**
* https://w3c.github.io/aria/#namefromcontent
*/
function allowsNameFromContent(node) {
return hasAnyConcreteRoles(node, ["button", "cell", "checkbox", "columnheader", "gridcell", "heading", "label", "legend", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "row", "rowheader", "switch", "tab", "tooltip", "treeitem"]);
}
/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/100
*/
function isDescendantOfNativeHostLanguageTextAlternativeElement( // eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
node) {
return false;
}
/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/101
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
function computeTooltipAttributeValue(node) {
return null;
}
function getValueOfTextbox(element) {
if (isHTMLInputElement(element) || isHTMLTextAreaElement(element)) {
return element.value;
} // https://github.com/eps1lon/dom-accessibility-api/issues/4
return element.textContent || "";
}
function getTextualContent(declaration) {
var content = declaration.getPropertyValue("content");
if (/^["'].*["']$/.test(content)) {
return content.slice(1, -1);
}
return "";
}
/**
* https://html.spec.whatwg.org/multipage/forms.html#category-label
* TODO: form-associated custom elements
* @param element
*/
function isLabelableElement(element) {
var localName = getLocalName(element);
return localName === "button" || localName === "input" && element.getAttribute("type") !== "hidden" || localName === "meter" || localName === "output" || localName === "progress" || localName === "select" || localName === "textarea";
}
/**
* > [...], then the first such descendant in tree order is the label element's labeled control.
* -- https://html.spec.whatwg.org/multipage/forms.html#labeled-control
* @param element
*/
function findLabelableElement(element) {
if (isLabelableElement(element)) {
return element;
}
var labelableElement = null;
element.childNodes.forEach(function (childNode) {
if (labelableElement === null && isElement(childNode)) {
var descendantLabelableElement = findLabelableElement(childNode);
if (descendantLabelableElement !== null) {
labelableElement = descendantLabelableElement;
}
}
});
return labelableElement;
}
/**
* Polyfill of HTMLLabelElement.control
* https://html.spec.whatwg.org/multipage/forms.html#labeled-control
* @param label
*/
function getControlOfLabel(label) {
if (label.control !== undefined) {
return label.control;
}
var htmlFor = label.getAttribute("for");
if (htmlFor !== null) {
return label.ownerDocument.getElementById(htmlFor);
}
return findLabelableElement(label);
}
/**
* Polyfill of HTMLInputElement.labels
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels
* @param element
*/
function getLabels(element) {
var labelsProperty = element.labels;
if (labelsProperty === null) {
return labelsProperty;
}
if (labelsProperty !== undefined) {
return ArrayFrom(labelsProperty);
} // polyfill
if (!isLabelableElement(element)) {
return null;
}
var document = element.ownerDocument;
return ArrayFrom(document.querySelectorAll("label")).filter(function (label) {
return getControlOfLabel(label) === element;
});
}
/**
* Gets the contents of a slot used for computing the accname
* @param slot
*/
function getSlotContents(slot) {
// Computing the accessible name for elements containing slots is not
// currently defined in the spec. This implementation reflects the
// behavior of NVDA 2020.2/Firefox 81 and iOS VoiceOver/Safari 13.6.
var assignedNodes = slot.assignedNodes();
if (assignedNodes.length === 0) {
// if no nodes are assigned to the slot, it displays the default content
return ArrayFrom(slot.childNodes);
}
return assignedNodes;
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_te
* @param root
* @param [options]
* @param [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export function computeTextAlternative(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var consultedNodes = new SetLike();
var window = safeWindow(root);
var _options$compute = options.compute,
compute = _options$compute === void 0 ? "name" : _options$compute,
_options$computedStyl = options.computedStyleSupportsPseudoElements,
computedStyleSupportsPseudoElements = _options$computedStyl === void 0 ? options.getComputedStyle !== undefined : _options$computedStyl,
_options$getComputedS = options.getComputedStyle,
getComputedStyle = _options$getComputedS === void 0 ? window.getComputedStyle.bind(window) : _options$getComputedS; // 2F.i
function computeMiscTextAlternative(node, context) {
var accumulatedText = "";
if (isElement(node) && computedStyleSupportsPseudoElements) {
var pseudoBefore = getComputedStyle(node, "::before");
var beforeContent = getTextualContent(pseudoBefore);
accumulatedText = "".concat(beforeContent, " ").concat(accumulatedText);
} // FIXME: Including aria-owns is not defined in the spec
// But it is required in the web-platform-test
var childNodes = isHTMLSlotElement(node) ? getSlotContents(node) : ArrayFrom(node.childNodes).concat(queryIdRefs(node, "aria-owns"));
childNodes.forEach(function (child) {
var result = computeTextAlternative(child, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
}); // TODO: Unclear why display affects delimiter
// see https://github.com/w3c/accname/issues/3
var display = isElement(child) ? getComputedStyle(child).getPropertyValue("display") : "inline";
var separator = display !== "inline" ? " " : ""; // trailing separator for wpt tests
accumulatedText += "".concat(separator).concat(result).concat(separator);
});
if (isElement(node) && computedStyleSupportsPseudoElements) {
var pseudoAfter = getComputedStyle(node, "::after");
var afterContent = getTextualContent(pseudoAfter);
accumulatedText = "".concat(accumulatedText, " ").concat(afterContent);
}
return accumulatedText;
}
function computeElementTextAlternative(node) {
if (!isElement(node)) {
return null;
}
/**
*
* @param element
* @param attributeName
* @returns A string non-empty string or `null`
*/
function useAttribute(element, attributeName) {
var attribute = element.getAttributeNode(attributeName);
if (attribute !== null && !consultedNodes.has(attribute) && attribute.value.trim() !== "") {
consultedNodes.add(attribute);
return attribute.value;
}
return null;
} // https://w3c.github.io/html-aam/#fieldset-and-legend-elements
if (isHTMLFieldSetElement(node)) {
consultedNodes.add(node);
var children = ArrayFrom(node.childNodes);
for (var i = 0; i < children.length; i += 1) {
var child = children[i];
if (isHTMLLegendElement(child)) {
return computeTextAlternative(child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
} else if (isHTMLTableElement(node)) {
// https://w3c.github.io/html-aam/#table-element
consultedNodes.add(node);
var _children = ArrayFrom(node.childNodes);
for (var _i = 0; _i < _children.length; _i += 1) {
var _child = _children[_i];
if (isHTMLTableCaptionElement(_child)) {
return computeTextAlternative(_child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
} else if (isSVGSVGElement(node)) {
// https://www.w3.org/TR/svg-aam-1.0/
consultedNodes.add(node);
var _children2 = ArrayFrom(node.childNodes);
for (var _i2 = 0; _i2 < _children2.length; _i2 += 1) {
var _child2 = _children2[_i2];
if (isSVGTitleElement(_child2)) {
return _child2.textContent;
}
}
return null;
} else if (getLocalName(node) === "img" || getLocalName(node) === "area") {
// https://w3c.github.io/html-aam/#area-element
// https://w3c.github.io/html-aam/#img-element
var nameFromAlt = useAttribute(node, "alt");
if (nameFromAlt !== null) {
return nameFromAlt;
}
} else if (isHTMLOptGroupElement(node)) {
var nameFromLabel = useAttribute(node, "label");
if (nameFromLabel !== null) {
return nameFromLabel;
}
}
if (isHTMLInputElement(node) && (node.type === "button" || node.type === "submit" || node.type === "reset")) {
// 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
var nameFromValue = useAttribute(node, "value");
if (nameFromValue !== null) {
return nameFromValue;
} // TODO: l10n
if (node.type === "submit") {
return "Submit";
} // TODO: l10n
if (node.type === "reset") {
return "Reset";
}
}
var labels = getLabels(node);
if (labels !== null && labels.length !== 0) {
consultedNodes.add(node);
return ArrayFrom(labels).map(function (element) {
return computeTextAlternative(element, {
isEmbeddedInLabel: true,
isReferenced: false,
recursion: true
});
}).filter(function (label) {
return label.length > 0;
}).join(" ");
} // https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation
// TODO: wpt test consider label elements but html-aam does not mention them
// We follow existing implementations over spec
if (isHTMLInputElement(node) && node.type === "image") {
var _nameFromAlt = useAttribute(node, "alt");
if (_nameFromAlt !== null) {
return _nameFromAlt;
}
var nameFromTitle = useAttribute(node, "title");
if (nameFromTitle !== null) {
return nameFromTitle;
} // TODO: l10n
return "Submit Query";
}
return useAttribute(node, "title");
}
function computeTextAlternative(current, context) {
if (consultedNodes.has(current)) {
return "";
} // special casing, cheating to make tests pass
// https://github.com/w3c/accname/issues/67
if (hasAnyConcreteRoles(current, ["menu"])) {
consultedNodes.add(current);
return "";
} // 2A
if (isHidden(current, getComputedStyle) && !context.isReferenced) {
consultedNodes.add(current);
return "";
} // 2B
var labelElements = queryIdRefs(current, "aria-labelledby");
if (compute === "name" && !context.isReferenced && labelElements.length > 0) {
return labelElements.map(function (element) {
return computeTextAlternative(element, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: true,
// thais isn't recursion as specified, otherwise we would skip
// `aria-label` in
// <input id="myself" aria-label="foo" aria-labelledby="myself"
recursion: false
});
}).join(" ");
} // 2C
// Changed from the spec in anticipation of https://github.com/w3c/accname/issues/64
// spec says we should only consider skipping if we have a non-empty label
var skipToStep2E = context.recursion && isControl(current) && compute === "name";
if (!skipToStep2E) {
var ariaLabel = (isElement(current) && current.getAttribute("aria-label") || "").trim();
if (ariaLabel !== "" && compute === "name") {
consultedNodes.add(current);
return ariaLabel;
} // 2D
if (!isMarkedPresentational(current)) {
var elementTextAlternative = computeElementTextAlternative(current);
if (elementTextAlternative !== null) {
consultedNodes.add(current);
return elementTextAlternative;
}
}
} // 2E
if (skipToStep2E || context.isEmbeddedInLabel || context.isReferenced) {
if (hasAnyConcreteRoles(current, ["combobox", "listbox"])) {
consultedNodes.add(current);
var selectedOptions = querySelectedOptions(current);
if (selectedOptions.length === 0) {
// defined per test `name_heading_combobox`
return isHTMLInputElement(current) ? current.value : "";
}
return ArrayFrom(selectedOptions).map(function (selectedOption) {
return computeTextAlternative(selectedOption, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
});
}).join(" ");
}
if (hasAbstractRole(current, "range")) {
consultedNodes.add(current);
if (current.hasAttribute("aria-valuetext")) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard
return current.getAttribute("aria-valuetext");
}
if (current.hasAttribute("aria-valuenow")) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard
return current.getAttribute("aria-valuenow");
} // Otherwise, use the value as specified by a host language attribute.
return current.getAttribute("value") || "";
}
if (hasAnyConcreteRoles(current, ["textbox"])) {
consultedNodes.add(current);
return getValueOfTextbox(current);
}
} // 2F: https://w3c.github.io/accname/#step2F
if (allowsNameFromContent(current) || isElement(current) && context.isReferenced || isNativeHostLanguageTextAlternativeElement(current) || isDescendantOfNativeHostLanguageTextAlternativeElement(current)) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false
});
}
if (current.nodeType === current.TEXT_NODE) {
consultedNodes.add(current);
return current.textContent || "";
}
if (context.recursion) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false
});
}
var tooltipAttributeValue = computeTooltipAttributeValue(current);
if (tooltipAttributeValue !== null) {
consultedNodes.add(current);
return tooltipAttributeValue;
} // TODO should this be reachable?
consultedNodes.add(current);
return "";
}
return asFlatString(computeTextAlternative(root, {
isEmbeddedInLabel: false,
// by spec computeAccessibleDescription starts with the referenced elements as roots
isReferenced: compute === "description",
recursion: false
}));
}
//# sourceMappingURL=accessible-name-and-description.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,9 @@
import { ComputeTextAlternativeOptions } from "./accessible-name-and-description";
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_name
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export declare function computeAccessibleName(root: Element, options?: ComputeTextAlternativeOptions): string;
//# sourceMappingURL=accessible-name.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"accessible-name.d.ts","sourceRoot":"","sources":["../sources/accessible-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,6BAA6B,EAC7B,MAAM,mCAAmC,CAAC;AAsB3C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,6BAAkC,GACzC,MAAM,CAMR"}

View file

@ -0,0 +1,33 @@
"use strict";
exports.__esModule = true;
exports.computeAccessibleName = computeAccessibleName;
var _accessibleNameAndDescription = require("./accessible-name-and-description");
var _util = require("./util");
/**
* https://w3c.github.io/aria/#namefromprohibited
*/
function prohibitsNaming(node) {
return (0, _util.hasAnyConcreteRoles)(node, ["caption", "code", "deletion", "emphasis", "generic", "insertion", "paragraph", "presentation", "strong", "subscript", "superscript"]);
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_name
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
function computeAccessibleName(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (prohibitsNaming(root)) {
return "";
}
return (0, _accessibleNameAndDescription.computeTextAlternative)(root, options);
}
//# sourceMappingURL=accessible-name.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../sources/accessible-name.ts"],"names":["prohibitsNaming","node","computeAccessibleName","root","options"],"mappings":";;;;;AAAA;;AAIA;;AAEA;AACA;AACA;AACA,SAASA,eAAT,CAAyBC,IAAzB,EAA8C;AAC7C,SAAO,+BAAoBA,IAApB,EAA0B,CAChC,SADgC,EAEhC,MAFgC,EAGhC,UAHgC,EAIhC,UAJgC,EAKhC,SALgC,EAMhC,WANgC,EAOhC,WAPgC,EAQhC,cARgC,EAShC,QATgC,EAUhC,WAVgC,EAWhC,aAXgC,CAA1B,CAAP;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CACNC,IADM,EAGG;AAAA,MADTC,OACS,uEADgC,EAChC;;AACT,MAAIJ,eAAe,CAACG,IAAD,CAAnB,EAA2B;AAC1B,WAAO,EAAP;AACA;;AAED,SAAO,0DAAuBA,IAAvB,EAA6BC,OAA7B,CAAP;AACA","sourcesContent":["import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { hasAnyConcreteRoles } from \"./util\";\n\n/**\n * https://w3c.github.io/aria/#namefromprohibited\n */\nfunction prohibitsNaming(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"caption\",\n\t\t\"code\",\n\t\t\"deletion\",\n\t\t\"emphasis\",\n\t\t\"generic\",\n\t\t\"insertion\",\n\t\t\"paragraph\",\n\t\t\"presentation\",\n\t\t\"strong\",\n\t\t\"subscript\",\n\t\t\"superscript\",\n\t]);\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_name\n * @param root\n * @param [options]\n * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n */\nexport function computeAccessibleName(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tif (prohibitsNaming(root)) {\n\t\treturn \"\";\n\t}\n\n\treturn computeTextAlternative(root, options);\n}\n"],"file":"accessible-name.js"}

View file

@ -0,0 +1,27 @@
import { computeTextAlternative } from "./accessible-name-and-description.mjs";
import { hasAnyConcreteRoles } from "./util.mjs";
/**
* https://w3c.github.io/aria/#namefromprohibited
*/
function prohibitsNaming(node) {
return hasAnyConcreteRoles(node, ["caption", "code", "deletion", "emphasis", "generic", "insertion", "paragraph", "presentation", "strong", "subscript", "superscript"]);
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_name
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export function computeAccessibleName(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (prohibitsNaming(root)) {
return "";
}
return computeTextAlternative(root, options);
}
//# sourceMappingURL=accessible-name.mjs.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../sources/accessible-name.ts"],"names":["computeTextAlternative","hasAnyConcreteRoles","prohibitsNaming","node","computeAccessibleName","root","options"],"mappings":"AAAA,SACCA,sBADD,QAGO,uCAHP;AAIA,SAASC,mBAAT,QAAoC,YAApC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,CAAyBC,IAAzB,EAA8C;AAC7C,SAAOF,mBAAmB,CAACE,IAAD,EAAO,CAChC,SADgC,EAEhC,MAFgC,EAGhC,UAHgC,EAIhC,UAJgC,EAKhC,SALgC,EAMhC,WANgC,EAOhC,WAPgC,EAQhC,cARgC,EAShC,QATgC,EAUhC,WAVgC,EAWhC,aAXgC,CAAP,CAA1B;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,qBAAT,CACNC,IADM,EAGG;AAAA,MADTC,OACS,uEADgC,EAChC;;AACT,MAAIJ,eAAe,CAACG,IAAD,CAAnB,EAA2B;AAC1B,WAAO,EAAP;AACA;;AAED,SAAOL,sBAAsB,CAACK,IAAD,EAAOC,OAAP,CAA7B;AACA","sourcesContent":["import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { hasAnyConcreteRoles } from \"./util\";\n\n/**\n * https://w3c.github.io/aria/#namefromprohibited\n */\nfunction prohibitsNaming(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"caption\",\n\t\t\"code\",\n\t\t\"deletion\",\n\t\t\"emphasis\",\n\t\t\"generic\",\n\t\t\"insertion\",\n\t\t\"paragraph\",\n\t\t\"presentation\",\n\t\t\"strong\",\n\t\t\"subscript\",\n\t\t\"superscript\",\n\t]);\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_name\n * @param root\n * @param [options]\n * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n */\nexport function computeAccessibleName(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tif (prohibitsNaming(root)) {\n\t\treturn \"\";\n\t}\n\n\treturn computeTextAlternative(root, options);\n}\n"],"file":"accessible-name.mjs"}

View file

@ -0,0 +1,2 @@
export default function getRole(element: Element): string | null;
//# sourceMappingURL=getRole.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"getRole.d.ts","sourceRoot":"","sources":["../sources/getRole.ts"],"names":[],"mappings":"AAkHA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAa/D"}

200
web/node_modules/dom-accessibility-api/dist/getRole.js generated vendored Normal file
View file

@ -0,0 +1,200 @@
"use strict";
exports.__esModule = true;
exports.default = getRole;
var _util = require("./util");
// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html
var localNameToRoleMappings = {
article: "article",
aside: "complementary",
button: "button",
datalist: "listbox",
dd: "definition",
details: "group",
dialog: "dialog",
dt: "term",
fieldset: "group",
figure: "figure",
// WARNING: Only with an accessible name
form: "form",
footer: "contentinfo",
h1: "heading",
h2: "heading",
h3: "heading",
h4: "heading",
h5: "heading",
h6: "heading",
header: "banner",
hr: "separator",
html: "document",
legend: "legend",
li: "listitem",
math: "math",
main: "main",
menu: "list",
nav: "navigation",
ol: "list",
optgroup: "group",
// WARNING: Only in certain context
option: "option",
output: "status",
progress: "progressbar",
// WARNING: Only with an accessible name
section: "region",
summary: "button",
table: "table",
tbody: "rowgroup",
textarea: "textbox",
tfoot: "rowgroup",
// WARNING: Only in certain context
td: "cell",
th: "columnheader",
thead: "rowgroup",
tr: "row",
ul: "list"
};
var prohibitedAttributes = {
caption: new Set(["aria-label", "aria-labelledby"]),
code: new Set(["aria-label", "aria-labelledby"]),
deletion: new Set(["aria-label", "aria-labelledby"]),
emphasis: new Set(["aria-label", "aria-labelledby"]),
generic: new Set(["aria-label", "aria-labelledby", "aria-roledescription"]),
insertion: new Set(["aria-label", "aria-labelledby"]),
paragraph: new Set(["aria-label", "aria-labelledby"]),
presentation: new Set(["aria-label", "aria-labelledby"]),
strong: new Set(["aria-label", "aria-labelledby"]),
subscript: new Set(["aria-label", "aria-labelledby"]),
superscript: new Set(["aria-label", "aria-labelledby"])
};
/**
*
* @param element
* @param role The role used for this element. This is specified to control whether you want to use the implicit or explicit role.
*/
function hasGlobalAriaAttributes(element, role) {
// https://rawgit.com/w3c/aria/stable/#global_states
// commented attributes are deprecated
return ["aria-atomic", "aria-busy", "aria-controls", "aria-current", "aria-describedby", "aria-details", // "disabled",
"aria-dropeffect", // "errormessage",
"aria-flowto", "aria-grabbed", // "haspopup",
"aria-hidden", // "invalid",
"aria-keyshortcuts", "aria-label", "aria-labelledby", "aria-live", "aria-owns", "aria-relevant", "aria-roledescription"].some(function (attributeName) {
var _prohibitedAttributes;
return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) !== null && _prohibitedAttributes !== void 0 && _prohibitedAttributes.has(attributeName));
});
}
function ignorePresentationalRole(element, implicitRole) {
// https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none
return hasGlobalAriaAttributes(element, implicitRole);
}
function getRole(element) {
var explicitRole = getExplicitRole(element);
if (explicitRole === null || explicitRole === "presentation") {
var implicitRole = getImplicitRole(element);
if (explicitRole !== "presentation" || ignorePresentationalRole(element, implicitRole || "")) {
return implicitRole;
}
}
return explicitRole;
}
function getImplicitRole(element) {
var mappedByTag = localNameToRoleMappings[(0, _util.getLocalName)(element)];
if (mappedByTag !== undefined) {
return mappedByTag;
}
switch ((0, _util.getLocalName)(element)) {
case "a":
case "area":
case "link":
if (element.hasAttribute("href")) {
return "link";
}
break;
case "img":
if (element.getAttribute("alt") === "" && !ignorePresentationalRole(element, "img")) {
return "presentation";
}
return "img";
case "input":
{
var _ref = element,
type = _ref.type;
switch (type) {
case "button":
case "image":
case "reset":
case "submit":
return "button";
case "checkbox":
case "radio":
return type;
case "range":
return "slider";
case "email":
case "tel":
case "text":
case "url":
if (element.hasAttribute("list")) {
return "combobox";
}
return "textbox";
case "search":
if (element.hasAttribute("list")) {
return "combobox";
}
return "searchbox";
default:
return null;
}
}
case "select":
if (element.hasAttribute("multiple") || element.size > 1) {
return "listbox";
}
return "combobox";
}
return null;
}
function getExplicitRole(element) {
var role = element.getAttribute("role");
if (role !== null) {
var explicitRole = role.trim().split(" ")[0]; // String.prototype.split(sep, limit) will always return an array with at least one member
// as long as limit is either undefined or > 0
if (explicitRole.length > 0) {
return explicitRole;
}
}
return null;
}
//# sourceMappingURL=getRole.js.map

File diff suppressed because one or more lines are too long

194
web/node_modules/dom-accessibility-api/dist/getRole.mjs generated vendored Normal file
View file

@ -0,0 +1,194 @@
// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html
import { getLocalName } from "./util.mjs";
var localNameToRoleMappings = {
article: "article",
aside: "complementary",
button: "button",
datalist: "listbox",
dd: "definition",
details: "group",
dialog: "dialog",
dt: "term",
fieldset: "group",
figure: "figure",
// WARNING: Only with an accessible name
form: "form",
footer: "contentinfo",
h1: "heading",
h2: "heading",
h3: "heading",
h4: "heading",
h5: "heading",
h6: "heading",
header: "banner",
hr: "separator",
html: "document",
legend: "legend",
li: "listitem",
math: "math",
main: "main",
menu: "list",
nav: "navigation",
ol: "list",
optgroup: "group",
// WARNING: Only in certain context
option: "option",
output: "status",
progress: "progressbar",
// WARNING: Only with an accessible name
section: "region",
summary: "button",
table: "table",
tbody: "rowgroup",
textarea: "textbox",
tfoot: "rowgroup",
// WARNING: Only in certain context
td: "cell",
th: "columnheader",
thead: "rowgroup",
tr: "row",
ul: "list"
};
var prohibitedAttributes = {
caption: new Set(["aria-label", "aria-labelledby"]),
code: new Set(["aria-label", "aria-labelledby"]),
deletion: new Set(["aria-label", "aria-labelledby"]),
emphasis: new Set(["aria-label", "aria-labelledby"]),
generic: new Set(["aria-label", "aria-labelledby", "aria-roledescription"]),
insertion: new Set(["aria-label", "aria-labelledby"]),
paragraph: new Set(["aria-label", "aria-labelledby"]),
presentation: new Set(["aria-label", "aria-labelledby"]),
strong: new Set(["aria-label", "aria-labelledby"]),
subscript: new Set(["aria-label", "aria-labelledby"]),
superscript: new Set(["aria-label", "aria-labelledby"])
};
/**
*
* @param element
* @param role The role used for this element. This is specified to control whether you want to use the implicit or explicit role.
*/
function hasGlobalAriaAttributes(element, role) {
// https://rawgit.com/w3c/aria/stable/#global_states
// commented attributes are deprecated
return ["aria-atomic", "aria-busy", "aria-controls", "aria-current", "aria-describedby", "aria-details", // "disabled",
"aria-dropeffect", // "errormessage",
"aria-flowto", "aria-grabbed", // "haspopup",
"aria-hidden", // "invalid",
"aria-keyshortcuts", "aria-label", "aria-labelledby", "aria-live", "aria-owns", "aria-relevant", "aria-roledescription"].some(function (attributeName) {
var _prohibitedAttributes;
return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) !== null && _prohibitedAttributes !== void 0 && _prohibitedAttributes.has(attributeName));
});
}
function ignorePresentationalRole(element, implicitRole) {
// https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none
return hasGlobalAriaAttributes(element, implicitRole);
}
export default function getRole(element) {
var explicitRole = getExplicitRole(element);
if (explicitRole === null || explicitRole === "presentation") {
var implicitRole = getImplicitRole(element);
if (explicitRole !== "presentation" || ignorePresentationalRole(element, implicitRole || "")) {
return implicitRole;
}
}
return explicitRole;
}
function getImplicitRole(element) {
var mappedByTag = localNameToRoleMappings[getLocalName(element)];
if (mappedByTag !== undefined) {
return mappedByTag;
}
switch (getLocalName(element)) {
case "a":
case "area":
case "link":
if (element.hasAttribute("href")) {
return "link";
}
break;
case "img":
if (element.getAttribute("alt") === "" && !ignorePresentationalRole(element, "img")) {
return "presentation";
}
return "img";
case "input":
{
var _ref = element,
type = _ref.type;
switch (type) {
case "button":
case "image":
case "reset":
case "submit":
return "button";
case "checkbox":
case "radio":
return type;
case "range":
return "slider";
case "email":
case "tel":
case "text":
case "url":
if (element.hasAttribute("list")) {
return "combobox";
}
return "textbox";
case "search":
if (element.hasAttribute("list")) {
return "combobox";
}
return "searchbox";
default:
return null;
}
}
case "select":
if (element.hasAttribute("multiple") || element.size > 1) {
return "listbox";
}
return "combobox";
}
return null;
}
function getExplicitRole(element) {
var role = element.getAttribute("role");
if (role !== null) {
var explicitRole = role.trim().split(" ")[0]; // String.prototype.split(sep, limit) will always return an array with at least one member
// as long as limit is either undefined or > 0
if (explicitRole.length > 0) {
return explicitRole;
}
}
return null;
}
//# sourceMappingURL=getRole.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,4 @@
export { computeAccessibleDescription } from "./accessible-description";
export { computeAccessibleName } from "./accessible-name";
export { default as getRole } from "./getRole";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../sources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}

19
web/node_modules/dom-accessibility-api/dist/index.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
"use strict";
exports.__esModule = true;
exports.getRole = exports.computeAccessibleName = exports.computeAccessibleDescription = void 0;
var _accessibleDescription = require("./accessible-description");
exports.computeAccessibleDescription = _accessibleDescription.computeAccessibleDescription;
var _accessibleName = require("./accessible-name");
exports.computeAccessibleName = _accessibleName.computeAccessibleName;
var _getRole = _interopRequireDefault(require("./getRole"));
exports.getRole = _getRole.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../sources/index.ts"],"names":[],"mappings":";;;;;AAAA;;;;AACA;;;;AACA","sourcesContent":["export { computeAccessibleDescription } from \"./accessible-description\";\nexport { computeAccessibleName } from \"./accessible-name\";\nexport { default as getRole } from \"./getRole\";\n"],"file":"index.js"}

View file

@ -0,0 +1,4 @@
export { computeAccessibleDescription } from "./accessible-description.mjs";
export { computeAccessibleName } from "./accessible-name.mjs";
export { default as getRole } from "./getRole.mjs";
//# sourceMappingURL=index.mjs.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../sources/index.ts"],"names":["computeAccessibleDescription","computeAccessibleName","default","getRole"],"mappings":"AAAA,SAASA,4BAAT,QAA6C,8BAA7C;AACA,SAASC,qBAAT,QAAsC,uBAAtC;AACA,SAASC,OAAO,IAAIC,OAApB,QAAmC,eAAnC","sourcesContent":["export { computeAccessibleDescription } from \"./accessible-description\";\nexport { computeAccessibleName } from \"./accessible-name\";\nexport { default as getRole } from \"./getRole\";\n"],"file":"index.mjs"}

View file

@ -0,0 +1,14 @@
declare global {
class Set<T> {
constructor(items?: T[]);
add(value: T): this;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: unknown): void;
has(value: T): boolean;
readonly size: number;
}
}
declare const _default: typeof Set;
export default _default;
//# sourceMappingURL=SetLike.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"SetLike.d.ts","sourceRoot":"","sources":["../../sources/polyfills/SetLike.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACd,MAAM,GAAG,CAAC,CAAC;oBAEE,KAAK,CAAC,EAAE,CAAC,EAAE;QACvB,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;QACnB,KAAK,IAAI,IAAI;QACb,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;QACzB,OAAO,CACN,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EACtD,OAAO,CAAC,EAAE,OAAO,GACf,IAAI;QACP,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KAItB;CACD;;AAuCD,wBAA0D"}

View file

@ -0,0 +1,76 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// for environments without Set we fallback to arrays with unique members
var SetLike = /*#__PURE__*/function () {
function SetLike() {
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, SetLike);
_defineProperty(this, "items", void 0);
this.items = items;
}
_createClass(SetLike, [{
key: "add",
value: function add(value) {
if (this.has(value) === false) {
this.items.push(value);
}
return this;
}
}, {
key: "clear",
value: function clear() {
this.items = [];
}
}, {
key: "delete",
value: function _delete(value) {
var previousLength = this.items.length;
this.items = this.items.filter(function (item) {
return item !== value;
});
return previousLength !== this.items.length;
}
}, {
key: "forEach",
value: function forEach(callbackfn) {
var _this = this;
this.items.forEach(function (item) {
callbackfn(item, item, _this);
});
}
}, {
key: "has",
value: function has(value) {
return this.items.indexOf(value) !== -1;
}
}, {
key: "size",
get: function get() {
return this.items.length;
}
}]);
return SetLike;
}();
var _default = typeof Set === "undefined" ? Set : SetLike;
exports.default = _default;
//# sourceMappingURL=SetLike.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../../sources/polyfills/SetLike.ts"],"names":["SetLike","items","value","has","push","previousLength","length","filter","item","callbackfn","forEach","indexOf","Set"],"mappings":";;;;;;;;;;;;;AAmBA;IACMA,O;AAGL,qBAA6B;AAAA,QAAjBC,KAAiB,uEAAJ,EAAI;;AAAA;;AAAA;;AAC5B,SAAKA,KAAL,GAAaA,KAAb;AACA;;;;WAED,aAAIC,KAAJ,EAAoB;AACnB,UAAI,KAAKC,GAAL,CAASD,KAAT,MAAoB,KAAxB,EAA+B;AAC9B,aAAKD,KAAL,CAAWG,IAAX,CAAgBF,KAAhB;AACA;;AACD,aAAO,IAAP;AACA;;;WACD,iBAAc;AACb,WAAKD,KAAL,GAAa,EAAb;AACA;;;WACD,iBAAOC,KAAP,EAA0B;AACzB,UAAMG,cAAc,GAAG,KAAKJ,KAAL,CAAWK,MAAlC;AACA,WAAKL,KAAL,GAAa,KAAKA,KAAL,CAAWM,MAAX,CAAkB,UAACC,IAAD;AAAA,eAAUA,IAAI,KAAKN,KAAnB;AAAA,OAAlB,CAAb;AAEA,aAAOG,cAAc,KAAK,KAAKJ,KAAL,CAAWK,MAArC;AACA;;;WACD,iBAAQG,UAAR,EAAsE;AAAA;;AACrE,WAAKR,KAAL,CAAWS,OAAX,CAAmB,UAACF,IAAD,EAAU;AAC5BC,QAAAA,UAAU,CAACD,IAAD,EAAOA,IAAP,EAAa,KAAb,CAAV;AACA,OAFD;AAGA;;;WACD,aAAIN,KAAJ,EAAuB;AACtB,aAAO,KAAKD,KAAL,CAAWU,OAAX,CAAmBT,KAAnB,MAA8B,CAAC,CAAtC;AACA;;;SAED,eAAmB;AAClB,aAAO,KAAKD,KAAL,CAAWK,MAAlB;AACA;;;;;;eAGa,OAAOM,GAAP,KAAe,WAAf,GAA6BA,GAA7B,GAAmCZ,O","sourcesContent":["declare global {\n\tclass Set<T> {\n\t\t// es2015.collection.d.ts\n\t\tconstructor(items?: T[]);\n\t\tadd(value: T): this;\n\t\tclear(): void;\n\t\tdelete(value: T): boolean;\n\t\tforEach(\n\t\t\tcallbackfn: (value: T, value2: T, set: Set<T>) => void,\n\t\t\tthisArg?: unknown\n\t\t): void;\n\t\thas(value: T): boolean;\n\t\treadonly size: number;\n\n\t\t// es2015.iterable.d.ts\n\t\t// no implemennted\n\t}\n}\n\n// for environments without Set we fallback to arrays with unique members\nclass SetLike<T> implements Set<T> {\n\tprivate items: T[];\n\n\tconstructor(items: T[] = []) {\n\t\tthis.items = items;\n\t}\n\n\tadd(value: T): this {\n\t\tif (this.has(value) === false) {\n\t\t\tthis.items.push(value);\n\t\t}\n\t\treturn this;\n\t}\n\tclear(): void {\n\t\tthis.items = [];\n\t}\n\tdelete(value: T): boolean {\n\t\tconst previousLength = this.items.length;\n\t\tthis.items = this.items.filter((item) => item !== value);\n\n\t\treturn previousLength !== this.items.length;\n\t}\n\tforEach(callbackfn: (value: T, value2: T, set: Set<T>) => void): void {\n\t\tthis.items.forEach((item) => {\n\t\t\tcallbackfn(item, item, this);\n\t\t});\n\t}\n\thas(value: T): boolean {\n\t\treturn this.items.indexOf(value) !== -1;\n\t}\n\n\tget size(): number {\n\t\treturn this.items.length;\n\t}\n}\n\nexport default typeof Set === \"undefined\" ? Set : SetLike;\n"],"file":"SetLike.js"}

View file

@ -0,0 +1,69 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// for environments without Set we fallback to arrays with unique members
var SetLike = /*#__PURE__*/function () {
function SetLike() {
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, SetLike);
_defineProperty(this, "items", void 0);
this.items = items;
}
_createClass(SetLike, [{
key: "add",
value: function add(value) {
if (this.has(value) === false) {
this.items.push(value);
}
return this;
}
}, {
key: "clear",
value: function clear() {
this.items = [];
}
}, {
key: "delete",
value: function _delete(value) {
var previousLength = this.items.length;
this.items = this.items.filter(function (item) {
return item !== value;
});
return previousLength !== this.items.length;
}
}, {
key: "forEach",
value: function forEach(callbackfn) {
var _this = this;
this.items.forEach(function (item) {
callbackfn(item, item, _this);
});
}
}, {
key: "has",
value: function has(value) {
return this.items.indexOf(value) !== -1;
}
}, {
key: "size",
get: function get() {
return this.items.length;
}
}]);
return SetLike;
}();
export default typeof Set === "undefined" ? Set : SetLike;
//# sourceMappingURL=SetLike.mjs.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../../sources/polyfills/SetLike.ts"],"names":["SetLike","items","value","has","push","previousLength","length","filter","item","callbackfn","forEach","indexOf","Set"],"mappings":";;;;;;;;AAmBA;IACMA,O;AAGL,qBAA6B;AAAA,QAAjBC,KAAiB,uEAAJ,EAAI;;AAAA;;AAAA;;AAC5B,SAAKA,KAAL,GAAaA,KAAb;AACA;;;;WAED,aAAIC,KAAJ,EAAoB;AACnB,UAAI,KAAKC,GAAL,CAASD,KAAT,MAAoB,KAAxB,EAA+B;AAC9B,aAAKD,KAAL,CAAWG,IAAX,CAAgBF,KAAhB;AACA;;AACD,aAAO,IAAP;AACA;;;WACD,iBAAc;AACb,WAAKD,KAAL,GAAa,EAAb;AACA;;;WACD,iBAAOC,KAAP,EAA0B;AACzB,UAAMG,cAAc,GAAG,KAAKJ,KAAL,CAAWK,MAAlC;AACA,WAAKL,KAAL,GAAa,KAAKA,KAAL,CAAWM,MAAX,CAAkB,UAACC,IAAD;AAAA,eAAUA,IAAI,KAAKN,KAAnB;AAAA,OAAlB,CAAb;AAEA,aAAOG,cAAc,KAAK,KAAKJ,KAAL,CAAWK,MAArC;AACA;;;WACD,iBAAQG,UAAR,EAAsE;AAAA;;AACrE,WAAKR,KAAL,CAAWS,OAAX,CAAmB,UAACF,IAAD,EAAU;AAC5BC,QAAAA,UAAU,CAACD,IAAD,EAAOA,IAAP,EAAa,KAAb,CAAV;AACA,OAFD;AAGA;;;WACD,aAAIN,KAAJ,EAAuB;AACtB,aAAO,KAAKD,KAAL,CAAWU,OAAX,CAAmBT,KAAnB,MAA8B,CAAC,CAAtC;AACA;;;SAED,eAAmB;AAClB,aAAO,KAAKD,KAAL,CAAWK,MAAlB;AACA;;;;;;AAGF,eAAe,OAAOM,GAAP,KAAe,WAAf,GAA6BA,GAA7B,GAAmCZ,OAAlD","sourcesContent":["declare global {\n\tclass Set<T> {\n\t\t// es2015.collection.d.ts\n\t\tconstructor(items?: T[]);\n\t\tadd(value: T): this;\n\t\tclear(): void;\n\t\tdelete(value: T): boolean;\n\t\tforEach(\n\t\t\tcallbackfn: (value: T, value2: T, set: Set<T>) => void,\n\t\t\tthisArg?: unknown\n\t\t): void;\n\t\thas(value: T): boolean;\n\t\treadonly size: number;\n\n\t\t// es2015.iterable.d.ts\n\t\t// no implemennted\n\t}\n}\n\n// for environments without Set we fallback to arrays with unique members\nclass SetLike<T> implements Set<T> {\n\tprivate items: T[];\n\n\tconstructor(items: T[] = []) {\n\t\tthis.items = items;\n\t}\n\n\tadd(value: T): this {\n\t\tif (this.has(value) === false) {\n\t\t\tthis.items.push(value);\n\t\t}\n\t\treturn this;\n\t}\n\tclear(): void {\n\t\tthis.items = [];\n\t}\n\tdelete(value: T): boolean {\n\t\tconst previousLength = this.items.length;\n\t\tthis.items = this.items.filter((item) => item !== value);\n\n\t\treturn previousLength !== this.items.length;\n\t}\n\tforEach(callbackfn: (value: T, value2: T, set: Set<T>) => void): void {\n\t\tthis.items.forEach((item) => {\n\t\t\tcallbackfn(item, item, this);\n\t\t});\n\t}\n\thas(value: T): boolean {\n\t\treturn this.items.indexOf(value) !== -1;\n\t}\n\n\tget size(): number {\n\t\treturn this.items.length;\n\t}\n}\n\nexport default typeof Set === \"undefined\" ? Set : SetLike;\n"],"file":"SetLike.mjs"}

View file

@ -0,0 +1,6 @@
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
export default function arrayFrom<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
//# sourceMappingURL=array.from.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"array.from.d.ts","sourceRoot":"","sources":["../../sources/polyfills/array.from.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC"}

View file

@ -0,0 +1,99 @@
"use strict";
exports.__esModule = true;
exports.default = arrayFrom;
/**
* @source {https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Polyfill}
* but without thisArg (too hard to type, no need to `this`)
*/
var toStr = Object.prototype.toString;
function isCallable(fn) {
return typeof fn === "function" || toStr.call(fn) === "[object Function]";
}
function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
}
var maxSafeInteger = Math.pow(2, 53) - 1;
function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
}
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
function arrayFrom(arrayLike, mapFn) {
// 1. Let C be the this value.
// edit(@eps1lon): we're not calling it as Array.from
var C = Array; // 2. Let items be ToObject(arrayLike).
var items = Object(arrayLike); // 3. ReturnIfAbrupt(items).
if (arrayLike == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
} // 4. If mapfn is undefined, then let mapping be false.
// const mapFn = arguments.length > 1 ? arguments[1] : void undefined;
if (typeof mapFn !== "undefined") {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError("Array.from: when provided, the second argument must be a function");
}
} // 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length); // 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method
// of C with an argument list containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Let k be 0.
var k = 0; // 17. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = mapFn(kValue, k);
} else {
A[k] = kValue;
}
k += 1;
} // 18. Let putStatus be Put(A, "length", len, true).
A.length = len; // 20. Return A.
return A;
}
//# sourceMappingURL=array.from.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,94 @@
/**
* @source {https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Polyfill}
* but without thisArg (too hard to type, no need to `this`)
*/
var toStr = Object.prototype.toString;
function isCallable(fn) {
return typeof fn === "function" || toStr.call(fn) === "[object Function]";
}
function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
}
var maxSafeInteger = Math.pow(2, 53) - 1;
function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
}
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
export default function arrayFrom(arrayLike, mapFn) {
// 1. Let C be the this value.
// edit(@eps1lon): we're not calling it as Array.from
var C = Array; // 2. Let items be ToObject(arrayLike).
var items = Object(arrayLike); // 3. ReturnIfAbrupt(items).
if (arrayLike == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
} // 4. If mapfn is undefined, then let mapping be false.
// const mapFn = arguments.length > 1 ? arguments[1] : void undefined;
if (typeof mapFn !== "undefined") {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError("Array.from: when provided, the second argument must be a function");
}
} // 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length); // 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method
// of C with an argument list containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Let k be 0.
var k = 0; // 17. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = mapFn(kValue, k);
} else {
A[k] = kValue;
}
k += 1;
} // 18. Let putStatus be Put(A, "length", len, true).
A.length = len; // 20. Return A.
return A;
}
//# sourceMappingURL=array.from.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=iterator.d.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"iterator.d.js"}

View file

@ -0,0 +1,2 @@
//# sourceMappingURL=iterator.d.mjs.map

View file

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"iterator.d.mjs"}

28
web/node_modules/dom-accessibility-api/dist/util.d.ts generated vendored Normal file
View file

@ -0,0 +1,28 @@
/**
* Safe Element.localName for all supported environments
* @param element
*/
export declare function getLocalName(element: Element): string;
export declare function isElement(node: Node | null): node is Element;
export declare function isHTMLTableCaptionElement(node: Node | null): node is HTMLTableCaptionElement;
export declare function isHTMLInputElement(node: Node | null): node is HTMLInputElement;
export declare function isHTMLOptGroupElement(node: Node | null): node is HTMLOptGroupElement;
export declare function isHTMLSelectElement(node: Node | null): node is HTMLSelectElement;
export declare function isHTMLTableElement(node: Node | null): node is HTMLTableElement;
export declare function isHTMLTextAreaElement(node: Node | null): node is HTMLTextAreaElement;
export declare function safeWindow(node: Node): Window;
export declare function isHTMLFieldSetElement(node: Node | null): node is HTMLFieldSetElement;
export declare function isHTMLLegendElement(node: Node | null): node is HTMLLegendElement;
export declare function isHTMLSlotElement(node: Node | null): node is HTMLSlotElement;
export declare function isSVGElement(node: Node | null): node is SVGElement;
export declare function isSVGSVGElement(node: Node | null): node is SVGSVGElement;
export declare function isSVGTitleElement(node: Node | null): node is SVGTitleElement;
/**
*
* @param {Node} node -
* @param {string} attributeName -
* @returns {Element[]} -
*/
export declare function queryIdRefs(node: Node, attributeName: string): Element[];
export declare function hasAnyConcreteRoles(node: Node, roles: Array<string | null>): node is Element;
//# sourceMappingURL=util.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../sources/util.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAOrD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAE5D;AAED,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,uBAAuB,CAEjC;AAED,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,gBAAgB,CAE1B;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,mBAAmB,CAE7B;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,iBAAiB,CAE3B;AAED,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,gBAAgB,CAE1B;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,mBAAmB,CAE7B;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQ7C;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,mBAAmB,CAE7B;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,iBAAiB,CAE3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,eAAe,CAE5E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,UAAU,CAElE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,aAAa,CAExE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,eAAe,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,EAAE,CAcxE;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GACzB,IAAI,IAAI,OAAO,CAKjB"}

131
web/node_modules/dom-accessibility-api/dist/util.js generated vendored Normal file
View file

@ -0,0 +1,131 @@
"use strict";
exports.__esModule = true;
exports.getLocalName = getLocalName;
exports.isElement = isElement;
exports.isHTMLTableCaptionElement = isHTMLTableCaptionElement;
exports.isHTMLInputElement = isHTMLInputElement;
exports.isHTMLOptGroupElement = isHTMLOptGroupElement;
exports.isHTMLSelectElement = isHTMLSelectElement;
exports.isHTMLTableElement = isHTMLTableElement;
exports.isHTMLTextAreaElement = isHTMLTextAreaElement;
exports.safeWindow = safeWindow;
exports.isHTMLFieldSetElement = isHTMLFieldSetElement;
exports.isHTMLLegendElement = isHTMLLegendElement;
exports.isHTMLSlotElement = isHTMLSlotElement;
exports.isSVGElement = isSVGElement;
exports.isSVGSVGElement = isSVGSVGElement;
exports.isSVGTitleElement = isSVGTitleElement;
exports.queryIdRefs = queryIdRefs;
exports.hasAnyConcreteRoles = hasAnyConcreteRoles;
var _getRole = _interopRequireDefault(require("./getRole"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Safe Element.localName for all supported environments
* @param element
*/
function getLocalName(element) {
var _element$localName;
return (// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
(_element$localName = element.localName) !== null && _element$localName !== void 0 ? _element$localName : // eslint-disable-next-line no-restricted-properties -- required for the fallback
element.tagName.toLowerCase()
);
}
function isElement(node) {
return node !== null && node.nodeType === node.ELEMENT_NODE;
}
function isHTMLTableCaptionElement(node) {
return isElement(node) && getLocalName(node) === "caption";
}
function isHTMLInputElement(node) {
return isElement(node) && getLocalName(node) === "input";
}
function isHTMLOptGroupElement(node) {
return isElement(node) && getLocalName(node) === "optgroup";
}
function isHTMLSelectElement(node) {
return isElement(node) && getLocalName(node) === "select";
}
function isHTMLTableElement(node) {
return isElement(node) && getLocalName(node) === "table";
}
function isHTMLTextAreaElement(node) {
return isElement(node) && getLocalName(node) === "textarea";
}
function safeWindow(node) {
var _ref = node.ownerDocument === null ? node : node.ownerDocument,
defaultView = _ref.defaultView;
if (defaultView === null) {
throw new TypeError("no window available");
}
return defaultView;
}
function isHTMLFieldSetElement(node) {
return isElement(node) && getLocalName(node) === "fieldset";
}
function isHTMLLegendElement(node) {
return isElement(node) && getLocalName(node) === "legend";
}
function isHTMLSlotElement(node) {
return isElement(node) && getLocalName(node) === "slot";
}
function isSVGElement(node) {
return isElement(node) && node.ownerSVGElement !== undefined;
}
function isSVGSVGElement(node) {
return isElement(node) && getLocalName(node) === "svg";
}
function isSVGTitleElement(node) {
return isSVGElement(node) && getLocalName(node) === "title";
}
/**
*
* @param {Node} node -
* @param {string} attributeName -
* @returns {Element[]} -
*/
function queryIdRefs(node, attributeName) {
if (isElement(node) && node.hasAttribute(attributeName)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check
var ids = node.getAttribute(attributeName).split(" ");
return ids.map(function (id) {
return node.ownerDocument.getElementById(id);
}).filter(function (element) {
return element !== null;
} // TODO: why does this not narrow?
);
}
return [];
}
function hasAnyConcreteRoles(node, roles) {
if (isElement(node)) {
return roles.indexOf((0, _getRole.default)(node)) !== -1;
}
return false;
}
//# sourceMappingURL=util.js.map

File diff suppressed because one or more lines are too long

92
web/node_modules/dom-accessibility-api/dist/util.mjs generated vendored Normal file
View file

@ -0,0 +1,92 @@
import getRole from "./getRole.mjs";
/**
* Safe Element.localName for all supported environments
* @param element
*/
export function getLocalName(element) {
var _element$localName;
return (// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
(_element$localName = element.localName) !== null && _element$localName !== void 0 ? _element$localName : // eslint-disable-next-line no-restricted-properties -- required for the fallback
element.tagName.toLowerCase()
);
}
export function isElement(node) {
return node !== null && node.nodeType === node.ELEMENT_NODE;
}
export function isHTMLTableCaptionElement(node) {
return isElement(node) && getLocalName(node) === "caption";
}
export function isHTMLInputElement(node) {
return isElement(node) && getLocalName(node) === "input";
}
export function isHTMLOptGroupElement(node) {
return isElement(node) && getLocalName(node) === "optgroup";
}
export function isHTMLSelectElement(node) {
return isElement(node) && getLocalName(node) === "select";
}
export function isHTMLTableElement(node) {
return isElement(node) && getLocalName(node) === "table";
}
export function isHTMLTextAreaElement(node) {
return isElement(node) && getLocalName(node) === "textarea";
}
export function safeWindow(node) {
var _ref = node.ownerDocument === null ? node : node.ownerDocument,
defaultView = _ref.defaultView;
if (defaultView === null) {
throw new TypeError("no window available");
}
return defaultView;
}
export function isHTMLFieldSetElement(node) {
return isElement(node) && getLocalName(node) === "fieldset";
}
export function isHTMLLegendElement(node) {
return isElement(node) && getLocalName(node) === "legend";
}
export function isHTMLSlotElement(node) {
return isElement(node) && getLocalName(node) === "slot";
}
export function isSVGElement(node) {
return isElement(node) && node.ownerSVGElement !== undefined;
}
export function isSVGSVGElement(node) {
return isElement(node) && getLocalName(node) === "svg";
}
export function isSVGTitleElement(node) {
return isSVGElement(node) && getLocalName(node) === "title";
}
/**
*
* @param {Node} node -
* @param {string} attributeName -
* @returns {Element[]} -
*/
export function queryIdRefs(node, attributeName) {
if (isElement(node) && node.hasAttribute(attributeName)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check
var ids = node.getAttribute(attributeName).split(" ");
return ids.map(function (id) {
return node.ownerDocument.getElementById(id);
}).filter(function (element) {
return element !== null;
} // TODO: why does this not narrow?
);
}
return [];
}
export function hasAnyConcreteRoles(node, roles) {
if (isElement(node)) {
return roles.indexOf(getRole(node)) !== -1;
}
return false;
}
//# sourceMappingURL=util.mjs.map

File diff suppressed because one or more lines are too long