Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dom-accessibility-api

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-accessibility-api - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

14

CHANGELOG.md
# dom-accessibility-api changelog
## 0.5.3
### Patch Changes
- [`76e8f93`](https://github.com/eps1lon/dom-accessibility-api/commit/76e8f93ccd8d6d3464d1b362a22163c501b9ea37) [#430](https://github.com/eps1lon/dom-accessibility-api/pull/430) Thanks [@ckundo](https://github.com/ckundo)! - Maintain `img` role for `img` with missing `alt` attribute.
Previously `<img />` would be treated the same as `<img alt />`.
`<img />` is now treated as `role="img"` [as specified](https://w3c.github.io/html-aam/#el-img-empty-alt).
* [`96d4438`](https://github.com/eps1lon/dom-accessibility-api/commit/96d443855b897fccb9fa09d5f595c502b23e6cf9) [#436](https://github.com/eps1lon/dom-accessibility-api/pull/436) Thanks [@eps1lon](https://github.com/eps1lon)! - Resolve presentational role conflicts when global WAI-ARIA states or properties (ARIA attributes) are used.
`<img alt="" />` used to have no role.
[By spec](https://w3c.github.io/html-aam/#el-img-empty-alt) it should have `role="presentation"` with no ARIA attributes or `role="img"` [otherwise](https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none).
## 0.5.2

@@ -4,0 +18,0 @@

67

dist/getRole.js

@@ -20,12 +20,2 @@ "use strict";

function getRole(element) {
var explicitRole = getExplicitRole(element);
if (explicitRole !== null) {
return explicitRole;
}
return getImplicitRole(element);
}
var localNameToRoleMappings = {

@@ -80,3 +70,54 @@ article: "article",

};
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 ? 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) {

@@ -100,7 +141,7 @@ var mappedByTag = localNameToRoleMappings[(0, _util.getLocalName)(element)];

case "img":
if ((element.getAttribute("alt") || "").length > 0) {
return "img";
if (element.getAttribute("alt") === "" && !ignorePresentationalRole(element, "img")) {
return "presentation";
}
break;
return "img";

@@ -107,0 +148,0 @@ case "input":

declare global {
class Set<T> {
constructor(items?: T[]);
add(value: T): this;

@@ -4,0 +5,0 @@ clear(): void;

@@ -17,5 +17,9 @@ "use strict";

function SetLike() {
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, SetLike);
_defineProperty(this, "items", []);
_defineProperty(this, "items", void 0);
this.items = items;
}

@@ -22,0 +26,0 @@

26

package.json
{
"name": "dom-accessibility-api",
"version": "0.5.2",
"version": "0.5.3",
"main": "dist/index.js",

@@ -43,11 +43,11 @@ "module": "dist/index.mjs",

"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.4",
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/preset-env": "^7.11.0",
"@babel/preset-env": "^7.11.5",
"@babel/preset-typescript": "^7.10.4",
"@changesets/changelog-github": "^0.2.7",
"@changesets/cli": "^2.10.1",
"@testing-library/dom": "^7.22.5",
"@types/jest": "^26.0.10",
"@changesets/cli": "^2.10.3",
"@testing-library/dom": "^7.24.3",
"@types/jest": "^26.0.14",
"@typescript-eslint/eslint-plugin": "^3.10.1",

@@ -57,5 +57,5 @@ "@typescript-eslint/parser": "^3.9.1",

"cross-env": "^7.0.2",
"cypress": "^5.0.0",
"eslint": "^7.7.0",
"eslint-plugin-jest": "^23.20.0",
"cypress": "^5.2.0",
"eslint": "^7.10.0",
"eslint-plugin-jest": "^24.0.2",
"jest": "^26.4.2",

@@ -68,5 +68,5 @@ "jest-diff": "^26.4.2",

"minimatch": "^3.0.4",
"mocha": "^8.1.1",
"mocha": "^8.1.3",
"mocha-sugar-free": "^1.4.0",
"prettier": "^2.0.5",
"prettier": "^2.1.2",
"q": "^1.5.1",

@@ -77,3 +77,3 @@ "request": "^2.88",

"serve": "^11.3.2",
"typescript": "^4.0.2"
"typescript": "^4.0.3"
},

@@ -80,0 +80,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc