dom-accessibility-api
Advanced tools
Comparing version 0.5.4 to 0.5.5
# dom-accessibility-api changelog | ||
## 0.5.5 | ||
### Patch Changes | ||
- [#627](https://github.com/eps1lon/dom-accessibility-api/pull/627) [`0485441`](https://github.com/eps1lon/dom-accessibility-api/commit/0485441e68cf728596d7140bdff2ac13280eefab) Thanks [@eps1lon](https://github.com/eps1lon)! - Ensure certain babel helpers aren't required | ||
Source: | ||
```diff | ||
-const [item] = list; | ||
+const item = list[0]; | ||
``` | ||
Transpiled: | ||
```diff | ||
-var _trim$split = list.trim().split(" "), | ||
-_trim$split2 = _slicedToArray(_trim$split, 1), | ||
-item = _trim$split2[0] | ||
+var item = list[0]; | ||
``` | ||
* [#629](https://github.com/eps1lon/dom-accessibility-api/pull/629) [`383bdb6`](https://github.com/eps1lon/dom-accessibility-api/commit/383bdb616c00105474c8607dd9e5aab4deaff7ed) Thanks [@eps1lon](https://github.com/eps1lon)! - Use label attribute for naming of `<optgroup>` elements. | ||
Given | ||
```jsx | ||
<select> | ||
<optgroup label="foo"> | ||
<option value="1">bar</option> | ||
</optgroup> | ||
</select> | ||
``` | ||
Previously the `<optgroup />` would not have an accessible name. | ||
Though [2D in `accname` 1.2](https://www.w3.org/TR/accname-1.2/) could be interpreted to use the `label` attribute: | ||
> Otherwise, if the current node's native markup provides an attribute (e.g. title) or element (e.g. HTML label) that defines a text alternative, return that alternative [...] | ||
This was confirmed in NVDA + FireFox. | ||
## 0.5.4 | ||
@@ -4,0 +45,0 @@ |
@@ -10,3 +10,3 @@ "use strict"; | ||
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 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; } | ||
@@ -13,0 +13,0 @@ 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; } |
@@ -391,2 +391,8 @@ "use strict"; | ||
} | ||
} else if ((0, _util.isHTMLOptGroupElement)(node)) { | ||
var nameFromLabel = useAttribute(node, "label"); | ||
if (nameFromLabel !== null) { | ||
return nameFromLabel; | ||
} | ||
} | ||
@@ -393,0 +399,0 @@ |
@@ -8,14 +8,3 @@ "use strict"; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html | ||
var localNameToRoleMappings = { | ||
@@ -99,3 +88,3 @@ article: "article", | ||
return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) === null || _prohibitedAttributes === void 0 ? void 0 : _prohibitedAttributes.has(attributeName)); | ||
return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) !== null && _prohibitedAttributes !== void 0 && _prohibitedAttributes.has(attributeName)); | ||
}); | ||
@@ -200,9 +189,9 @@ } | ||
function getExplicitRole(element) { | ||
if (element.hasAttribute("role")) { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check | ||
var _trim$split = element.getAttribute("role").trim().split(" "), | ||
_trim$split2 = _slicedToArray(_trim$split, 1), | ||
explicitRole = _trim$split2[0]; | ||
var role = element.getAttribute("role"); | ||
if (explicitRole !== undefined && explicitRole.length > 0) { | ||
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; | ||
@@ -209,0 +198,0 @@ } |
@@ -9,2 +9,3 @@ /** | ||
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; | ||
@@ -11,0 +12,0 @@ export declare function isHTMLTableElement(node: Node | null): node is HTMLTableElement; |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.isHTMLInputElement = isHTMLInputElement; | ||
exports.isHTMLOptGroupElement = isHTMLOptGroupElement; | ||
exports.isHTMLSelectElement = isHTMLSelectElement; | ||
@@ -51,2 +52,6 @@ exports.isHTMLTableElement = isHTMLTableElement; | ||
function isHTMLOptGroupElement(node) { | ||
return isElement(node) && getLocalName(node) === "optgroup"; | ||
} | ||
function isHTMLSelectElement(node) { | ||
@@ -53,0 +58,0 @@ return isElement(node) && getLocalName(node) === "select"; |
{ | ||
"name": "dom-accessibility-api", | ||
"version": "0.5.4", | ||
"description": "Implements https://w3c.github.io/accname/", | ||
"version": "0.5.5", | ||
"main": "dist/index.js", | ||
@@ -43,28 +44,28 @@ "module": "dist/index.mjs", | ||
"devDependencies": { | ||
"@babel/cli": "^7.11.6", | ||
"@babel/core": "^7.11.6", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/preset-typescript": "^7.10.4", | ||
"@changesets/changelog-github": "^0.2.7", | ||
"@changesets/cli": "^2.10.3", | ||
"@testing-library/dom": "^7.24.3", | ||
"@types/jest": "^26.0.14", | ||
"@typescript-eslint/eslint-plugin": "^3.10.1", | ||
"@typescript-eslint/parser": "^3.9.1", | ||
"concurrently": "^5.3.0", | ||
"cross-env": "^7.0.2", | ||
"cypress": "^5.3.0", | ||
"eslint": "^7.10.0", | ||
"eslint-plugin-jest": "^24.0.2", | ||
"jest": "^26.4.2", | ||
"jest-diff": "^26.4.2", | ||
"jest-environment-jsdom": "^26.3.0", | ||
"jest-junit": "^12.0.0", | ||
"js-yaml": "^3.14.0", | ||
"jsdom": "^16.4.0", | ||
"@babel/cli": "^7.14.3", | ||
"@babel/core": "^7.14.3", | ||
"@babel/plugin-proposal-class-properties": "^7.13.0", | ||
"@babel/preset-env": "^7.14.2", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@changesets/changelog-github": "^0.4.0", | ||
"@changesets/cli": "^2.16.0", | ||
"@testing-library/dom": "^7.31.0", | ||
"@types/jest": "^26.0.23", | ||
"@typescript-eslint/eslint-plugin": "^4.24.0", | ||
"@typescript-eslint/parser": "^4.24.0", | ||
"concurrently": "^6.2.0", | ||
"cross-env": "^7.0.3", | ||
"cypress": "^7.4.0", | ||
"eslint": "^7.27.0", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"jest": "^27.0.3", | ||
"jest-diff": "^27.0.2", | ||
"jest-environment-jsdom": "^27.0.3", | ||
"jest-junit": "^12.1.0", | ||
"js-yaml": "^4.1.0", | ||
"jsdom": "^16.6.0", | ||
"minimatch": "^3.0.4", | ||
"mocha": "^8.1.3", | ||
"mocha": "^8.4.0", | ||
"mocha-sugar-free": "^1.4.0", | ||
"prettier": "^2.1.2", | ||
"prettier": "^2.3.0", | ||
"q": "^1.5.1", | ||
@@ -75,3 +76,3 @@ "request": "^2.88", | ||
"serve": "^11.3.2", | ||
"typescript": "^4.0.3" | ||
"typescript": "^4.3.2" | ||
}, | ||
@@ -78,0 +79,0 @@ "resolutions": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
244405
1916