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

@vaadin/a11y-base

Package Overview
Dependencies
Maintainers
12
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vaadin/a11y-base - npm Package Compare versions

Comparing version 24.1.0-alpha3 to 24.1.0-alpha4

src/aria-id-reference.d.ts

6

package.json
{
"name": "@vaadin/a11y-base",
"version": "24.1.0-alpha3",
"version": "24.1.0-alpha4",
"publishConfig": {

@@ -35,3 +35,3 @@ "access": "public"

"@polymer/polymer": "^3.0.0",
"@vaadin/component-base": "24.1.0-alpha3",
"@vaadin/component-base": "24.1.0-alpha4",
"lit": "^2.0.0"

@@ -44,3 +44,3 @@ },

},
"gitHead": "077b4a8e8fff063b9eba4581af81f9e152cb852d"
"gitHead": "4494259f3b7532acb604a3048d5b29a4e14b9ca5"
}

@@ -32,2 +32,9 @@ /**

/**
* Defines the `aria-label` attribute of the target element.
*
* To remove the attribute, pass `null` as `label`.
*/
setAriaLabel(label: string | null): void;
/**
* Links the target element with a slotted label element

@@ -38,3 +45,3 @@ * via the target's attribute `aria-labelledby`.

*/
setLabelId(labelId: string | null): void;
setLabelId(labelId: string | null, fromUser: boolean | null): void;

@@ -41,0 +48,0 @@ /**

@@ -6,3 +6,7 @@ /**

*/
import { addValueToAttribute, removeValueFromAttribute } from '@vaadin/component-base/src/dom-utils.js';
import {
removeAriaIDReference,
restoreGeneratedAriaIDReference,
setAriaIDReference,
} from '@vaadin/a11y-base/src/aria-id-reference.js';

@@ -40,2 +44,3 @@ /**

this.__setHelperIdToAriaAttribute(this.__helperId);
this.setAriaLabel(this.__label);
}

@@ -56,2 +61,14 @@

/**
* Defines the `aria-label` attribute of the target element.
*
* To remove the attribute, pass `null` as `label`.
*
* @param {string | null | undefined} label
*/
setAriaLabel(label) {
this.__setAriaLabelToAttribute(label);
this.__label = label;
}
/**
* Links the target element with a slotted label element

@@ -64,5 +81,10 @@ * via the target's attribute `aria-labelledby`.

*/
setLabelId(labelId) {
this.__setLabelIdToAriaAttribute(labelId, this.__labelId);
this.__labelId = labelId;
setLabelId(labelId, fromUser = false) {
const oldLabelId = fromUser ? this.__labelIdFromUser : this.__labelId;
this.__setLabelIdToAriaAttribute(labelId, oldLabelId, fromUser);
if (fromUser) {
this.__labelIdFromUser = labelId;
} else {
this.__labelId = labelId;
}
}

@@ -99,8 +121,26 @@

/**
* @param {string | null | undefined} label
* @private
* */
__setAriaLabelToAttribute(label) {
if (!this.__target) {
return;
}
if (label) {
removeAriaIDReference(this.__target, 'aria-labelledby');
this.__target.setAttribute('aria-label', label);
} else if (this.__label) {
restoreGeneratedAriaIDReference(this.__target, 'aria-labelledby');
this.__target.removeAttribute('aria-label');
}
}
/**
* @param {string | null | undefined} labelId
* @param {string | null | undefined} oldLabelId
* @param {boolean | null | undefined} fromUser
* @private
*/
__setLabelIdToAriaAttribute(labelId, oldLabelId) {
this.__setAriaAttributeId('aria-labelledby', labelId, oldLabelId);
__setLabelIdToAriaAttribute(labelId, oldLabelId, fromUser) {
setAriaIDReference(this.__target, 'aria-labelledby', { newId: labelId, oldId: oldLabelId, fromUser });
}

@@ -116,7 +156,4 @@

// that should guarantee that it's announced when the group is entered.
if (this.__isGroupField) {
this.__setAriaAttributeId('aria-labelledby', errorId, oldErrorId);
} else {
this.__setAriaAttributeId('aria-describedby', errorId, oldErrorId);
}
const ariaAttribute = this.__isGroupField ? 'aria-labelledby' : 'aria-describedby';
setAriaIDReference(this.__target, ariaAttribute, { newId: errorId, oldId: oldErrorId, fromUser: false });
}

@@ -132,7 +169,4 @@

// that should guarantee that it's announced when the group is entered.
if (this.__isGroupField) {
this.__setAriaAttributeId('aria-labelledby', helperId, oldHelperId);
} else {
this.__setAriaAttributeId('aria-describedby', helperId, oldHelperId);
}
const ariaAttribute = this.__isGroupField ? 'aria-labelledby' : 'aria-describedby';
setAriaIDReference(this.__target, ariaAttribute, { newId: helperId, oldId: oldHelperId, fromUser: false });
}

@@ -160,21 +194,2 @@

}
/**
* @param {string | null | undefined} newId
* @param {string | null | undefined} oldId
* @private
*/
__setAriaAttributeId(attr, newId, oldId) {
if (!this.__target) {
return;
}
if (oldId) {
removeValueFromAttribute(this.__target, attr, oldId);
}
if (newId) {
addValueToAttribute(this.__target, attr, newId);
}
}
}
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