Socket
Socket
Sign inDemoInstall

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.4.6 to 0.4.7

8

CHANGELOG.md
# dom-accessibility-api changelog
## 0.4.7
### Patch Changes
- [`d6c4455`](https://github.com/eps1lon/dom-accessibility-api/commit/d6c44558250e898caa68e7b3eaa2f4d505078b3e) [#352](https://github.com/eps1lon/dom-accessibility-api/pull/352) Thanks [@eps1lon](https://github.com/eps1lon)! - Support native labels in IE 11
Also affects Edge < 18 and Firefox < 56.
## 0.4.6

@@ -4,0 +12,0 @@

86

dist/accessible-name-and-description.js

@@ -158,2 +158,84 @@ "use strict";

/**
* https://html.spec.whatwg.org/multipage/forms.html#category-label
* TODO: form-associated custom elements
* @param element
*/
function isLabelableElement(element) {
var tagName = element.tagName;
return tagName === "BUTTON" || tagName === "INPUT" && element.getAttribute("type") !== "hidden" || tagName === "METER" || tagName === "OUTPUT" || tagName === "PROGRESS" || tagName === "SELECT" || tagName === "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);
}
if (!isLabelableElement(element)) {
return null;
}
var document = element.ownerDocument;
return (0, _array.default)(document.querySelectorAll("label")).filter(function (label) {
return getControlOfLabel(label) === element;
});
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_te

@@ -310,5 +392,5 @@ * @param root

var labels = input.labels; // IE11 does not implement labels, TODO: verify with caniuse instead of mdn
var labels = getLabels(input);
if (labels === null || labels === undefined || labels.length === 0) {
if (labels === null || labels.length === 0) {
return null;

@@ -315,0 +397,0 @@ }

26

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

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

"devDependencies": {
"@babel/cli": "^7.10.4",
"@babel/core": "^7.10.4",
"@babel/cli": "^7.10.5",
"@babel/core": "^7.10.5",
"@babel/plugin-proposal-class-properties": "^7.10.4",

@@ -51,14 +51,14 @@ "@babel/preset-env": "^7.10.4",

"@changesets/cli": "^2.9.2",
"@testing-library/dom": "^7.20.1",
"@types/jest": "^26.0.4",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"@testing-library/dom": "^7.21.5",
"@types/jest": "^26.0.7",
"@typescript-eslint/eslint-plugin": "^3.7.0",
"@typescript-eslint/parser": "^3.7.0",
"concurrently": "^5.2.0",
"cross-env": "^7.0.2",
"cypress": "^4.10.0",
"eslint": "^7.4.0",
"eslint-plugin-jest": "^23.18.0",
"cypress": "^4.11.0",
"eslint": "^7.5.0",
"eslint-plugin-jest": "^23.18.2",
"jest": "^26.1.0",
"jest-diff": "^26.1.0",
"jest-junit": "^11.0.1",
"jest-junit": "^11.1.0",
"js-yaml": "^3.14.0",

@@ -72,6 +72,6 @@ "jsdom": "^16.3.0",

"request": "^2.88",
"request-promise-native": "^1.0.8",
"request-promise-native": "^1.0.9",
"rimraf": "^3.0.2",
"serve": "^11.3.2",
"typescript": "^3.9.6"
"typescript": "^3.9.7"
},

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

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