Socket
Socket
Sign inDemoInstall

dom-accessibility-api

Package Overview
Dependencies
0
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.3 to 0.4.4

dist/polyfills/iterator.d.js

42

CHANGELOG.md
# dom-accessibility-api changelog
## 0.4.4
### Patch Changes
- [`e79f620`](https://github.com/eps1lon/dom-accessibility-api/commit/e79f6209667b3b2de656a73dec0eea37c65d48a9) [#208](https://github.com/eps1lon/dom-accessibility-api/pull/208) Thanks [@eps1lon](https://github.com/eps1lon)! - Add support for node 14
* [`2c6a23b`](https://github.com/eps1lon/dom-accessibility-api/commit/2c6a23b3ec3e514d7db631e393749fac0ab33b5b) [#200](https://github.com/eps1lon/dom-accessibility-api/pull/200) Thanks [@eps1lon](https://github.com/eps1lon)! - Add `module` field
- [`737dfae`](https://github.com/eps1lon/dom-accessibility-api/commit/737dfae2b88a4ce94d59144a6aabf69f0a671edc) [#234](https://github.com/eps1lon/dom-accessibility-api/pull/234) Thanks [@willamzv](https://github.com/willamzv)! - Consider `<legend>` for the name of its `<fieldset>` element.
```html
<fieldset>
<legend><em>my</em> fieldset</legend>
</fieldset>
```
Computing the name for this fieldset would've returned an empty string previously. It now correctly computes `my fieldset` following the [accessible name computation for `fieldset` elements](https://w3c.github.io/html-aam/#fieldset-and-legend-elements)
* [`969da7d`](https://github.com/eps1lon/dom-accessibility-api/commit/969da7d454b3d83dc7259d910f40e7e16a6eb560) [#240](https://github.com/eps1lon/dom-accessibility-api/pull/240) Thanks [@eps1lon](https://github.com/eps1lon)! - Reduce over-transpilation
Switched from
- `for-of` to `.forEach` or a basic `for` loop
- `array.push(...otherArray)` to `push.apply(array, otherArray)`
This removed a bunch of babel junk that wasn't needed.
- [`d578329`](https://github.com/eps1lon/dom-accessibility-api/commit/d5783292ca49ae947bd95559030aa2c93c04565f) [#248](https://github.com/eps1lon/dom-accessibility-api/pull/248) Thanks [@eps1lon](https://github.com/eps1lon)! - Consider `<caption>` for the name of its `<table>` element.
```html
<table>
<caption>
<em>my</em>
table
</caption>
</table>
```
Computing the name for this table would've returned an empty string previously. It now correctly computes `my table` following the [accessible name computation for `table` elements](https://w3c.github.io/html-aam/#table-element)
* [`f1b2bd0`](https://github.com/eps1lon/dom-accessibility-api/commit/f1b2bd0434cafe65812acfb0e3a2942309eb9726) [#237](https://github.com/eps1lon/dom-accessibility-api/pull/237) Thanks [@eps1lon](https://github.com/eps1lon)! - Use nodeType and tagName for element type checks
## 0.4.3

@@ -4,0 +46,0 @@

127

dist/accessible-name.js

@@ -16,16 +16,6 @@ "use strict";

function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
/**
* implements https://w3c.github.io/accname/
*/
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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; }
/**

@@ -107,12 +97,2 @@ * Small utility that handles all the JS quirks with `this` which is important

/**
* All defined children. This include childNodes as well as owned (portaled) trees
* via aria-owns
* @param node
*/
function queryChildNodes(node) {
return (0, _array.default)(node.childNodes).concat(idRefs(node, "aria-owns"));
}
/**
* @param {Node} node -

@@ -156,9 +136,7 @@ * @returns {boolean} - As defined in step 2E of https://w3c.github.io/accname/#mapping_additional_nd_te

function querySelectorAllSubtree(element, selectors) {
var elements = [];
for (var _i = 0, _arr = [element].concat(_toConsumableArray(idRefs(element, "aria-owns"))); _i < _arr.length; _i++) {
var root = _arr[_i];
elements.push.apply(elements, _toConsumableArray((0, _array.default)(root.querySelectorAll(selectors))));
}
var elements = (0, _array.default)(element.querySelectorAll(selectors));
idRefs(element, "aria-owns").forEach(function (root) {
// babel transpiles this assuming an iterator
elements.push.apply(elements, (0, _array.default)(root.querySelectorAll(selectors)));
});
return elements;

@@ -180,3 +158,10 @@ }

/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/99
* 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
*/

@@ -186,3 +171,3 @@

function isNativeHostLanguageTextAlternativeElement(node) {
return false;
return (0, _util.isHTMLTableCaptionElement)(node);
}

@@ -202,3 +187,4 @@ /**

function isDescendantOfNativeHostLanguageTextAlternativeElement(node) {
function isDescendantOfNativeHostLanguageTextAlternativeElement( // eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
node) {
return false;

@@ -209,2 +195,3 @@ }

*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet

@@ -258,25 +245,18 @@

accumulatedText = "".concat(beforeContent, " ").concat(accumulatedText);
}
} // FIXME: This is not defined in the spec
// But it is required in the web-platform-test
var _iterator = _createForOfIteratorHelper(queryChildNodes(node)),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var child = _step.value;
var result = computeTextAlternative(child, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
}); // TODO: Unclear why display affects delimiter
var childNodes = (0, _array.default)(node.childNodes).concat(idRefs(node, "aria-owns"));
childNodes.forEach(function (child) {
var result = computeTextAlternative(child, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
}); // TODO: Unclear why display affects delimiter
var display = (0, _util.isElement)(node) && createGetComputedStyle(node, options)(node).getPropertyValue("display");
var separator = display !== "inline" ? " " : "";
accumulatedText += "".concat(separator).concat(result);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var display = (0, _util.isElement)(node) && createGetComputedStyle(node, options)(node).getPropertyValue("display");
var separator = display !== "inline" ? " " : "";
accumulatedText += "".concat(separator).concat(result);
});

@@ -320,2 +300,43 @@ if ((0, _util.isElement)(node)) {

function computeElementTextAlternative(node) {
// 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
});
}
}
return null;
} // https://w3c.github.io/html-aam/#table-element
if ((0, _util.isHTMLTableElement)(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.isHTMLTableCaptionElement)(_child)) {
return computeTextAlternative(_child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
return null;
}
if (!((0, _util.isHTMLInputElement)(node) || (0, _util.isHTMLSelectElement)(node) || (0, _util.isHTMLTextAreaElement)(node))) {

@@ -322,0 +343,0 @@ return null;

@@ -10,3 +10,3 @@ "use strict";

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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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); }

@@ -13,0 +13,0 @@ 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; }

@@ -6,3 +6,3 @@ declare global {

delete(value: T): boolean;
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: unknown): void;
has(value: T): boolean;

@@ -9,0 +9,0 @@ readonly size: number;

@@ -14,4 +14,6 @@ "use strict";

function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

@@ -21,4 +23,2 @@

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }

@@ -25,0 +25,0 @@

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 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;
//# sourceMappingURL=util.d.ts.map

@@ -5,26 +5,33 @@ "use strict";

exports.isElement = isElement;
exports.isHTMLTableCaptionElement = isHTMLTableCaptionElement;
exports.isHTMLInputElement = isHTMLInputElement;
exports.isHTMLSelectElement = isHTMLSelectElement;
exports.isHTMLTableElement = isHTMLTableElement;
exports.isHTMLTextAreaElement = isHTMLTextAreaElement;
exports.safeWindow = safeWindow;
exports.isHTMLFieldSetElement = isHTMLFieldSetElement;
exports.isHTMLLegendElement = isHTMLLegendElement;
function isElement(node) {
return (// @ts-ignore
node !== null && node instanceof node.ownerDocument.defaultView.Element
);
return node !== null && node.nodeType === node.ELEMENT_NODE;
}
function isHTMLTableCaptionElement(node) {
return isElement(node) && node.tagName === "CAPTION";
}
function isHTMLInputElement(node) {
return isElement(node) && // @ts-ignore
node instanceof node.ownerDocument.defaultView.HTMLInputElement;
return isElement(node) && node.tagName === "INPUT";
}
function isHTMLSelectElement(node) {
return isElement(node) && // @ts-ignore
node instanceof node.ownerDocument.defaultView.HTMLSelectElement;
return isElement(node) && node.tagName === "SELECT";
}
function isHTMLTableElement(node) {
return isElement(node) && node.tagName === "TABLE";
}
function isHTMLTextAreaElement(node) {
return isElement(node) && // @ts-ignore
node instanceof node.ownerDocument.defaultView.HTMLTextAreaElement;
return isElement(node) && node.tagName === "TEXTAREA";
}

@@ -42,2 +49,10 @@

}
function isHTMLFieldSetElement(node) {
return isElement(node) && node.tagName === "FIELDSET";
}
function isHTMLLegendElement(node) {
return isElement(node) && node.tagName === "LEGEND";
}
//# sourceMappingURL=util.js.map
{
"name": "dom-accessibility-api",
"version": "0.4.3",
"version": "0.4.4",
"main": "dist/index.js",
"module": "dist/index.mjs",
"type": "commonjs",

@@ -27,6 +28,7 @@ "exports": {

"format": "prettier \"**/*.{json,js,md,ts,yml}\" --write --ignore-path .prettierignore",
"lint": "eslint --report-unused-disable-directives \"sources/**/*.ts\"",
"lint": "eslint --report-unused-disable-directives \"sources/**/*.{js,ts}\"",
"release": "yarn build && yarn changeset publish",
"test": "jest",
"test:ci": "jest --ci --config jest.ci.config.js --runInBand",
"test": "jest --config scripts/jest/jest.config.js",
"test:ci": "jest --ci --config scripts/jest/jest.ci.config.js --runInBand",
"test:coverage": "jest --config scripts/jest/jest.coverage.config.js",
"test:types": "tsc -p tsconfig.json --noEmit",

@@ -39,3 +41,3 @@ "test:wpt:jsdom": "mocha tests/wpt-jsdom/run-wpts.js",

"wpt:init": "git submodule update --init --recursive",
"wpt:reset": "rimraf ./tests/wpt && yarn init-wpt",
"wpt:reset": "rimraf ./tests/wpt && yarn wpt:init",
"wpt:update": "git submodule update --recursive --remote && cd tests/wpt && python wpt.py manifest --path ../wpt-jsdom/wpt-manifest.json"

@@ -45,27 +47,28 @@ },

"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/core": "^7.9.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/plugin-transform-modules-commonjs": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/preset-typescript": "^7.9.0",
"@changesets/changelog-github": "^0.2.2",
"@changesets/cli": "^2.6.1",
"@testing-library/dom": "^7.1.0",
"@types/jest": "^25.1.4",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"concurrently": "^5.1.0",
"@changesets/changelog-github": "^0.2.6",
"@changesets/cli": "^2.7.1",
"@testing-library/dom": "^7.5.6",
"@types/jest": "^25.2.2",
"@typescript-eslint/eslint-plugin": "^3.0.0-alpha.25",
"@typescript-eslint/parser": "^3.0.0-alpha.25",
"concurrently": "^5.2.0",
"cross-env": "^7.0.2",
"cypress": "^4.2.0",
"eslint": "^6.8.0",
"jest": "^25.1.0",
"jest-diff": "^25.1.0",
"cypress": "^4.5.0",
"eslint": "^7.0.0",
"eslint-plugin-jest": "^23.13.1",
"jest": "^26.0.1",
"jest-diff": "^26.0.1",
"jest-environment-jsdom-thirteen": "^1.0.1",
"jest-junit": "^10.0.0",
"js-yaml": "^3.13.1",
"jsdom": "^16.2.1",
"jsdom": "^16.2.2",
"minimatch": "^3.0.4",
"mocha": "^7.1.1",
"mocha": "^7.1.2",
"mocha-sugar-free": "^1.4.0",
"prettier": "^2.0.1",
"prettier": "^2.0.5",
"q": "^1.5.1",

@@ -76,5 +79,6 @@ "request": "^2.88",

"serve": "^11.3.0",
"typescript": "^3.8.3"
"typescript": "^3.9.2"
},
"resolutions": {
"**/kind-of": "^6.0.3",
"**/minimist": "^1.2.2"

@@ -81,0 +85,0 @@ },

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc