@vaadin/a11y-base 25.3.0-alpha7 → 25.3.0-alpha8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/a11y-base",
3
- "version": "25.3.0-alpha7",
3
+ "version": "25.3.0-alpha8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,15 +32,15 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@open-wc/dedupe-mixin": "^1.3.0",
35
- "@vaadin/component-base": "25.3.0-alpha7",
35
+ "@vaadin/component-base": "25.3.0-alpha8",
36
36
  "lit": "^3.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@vaadin/chai-plugins": "25.3.0-alpha7",
40
- "@vaadin/test-runner-commands": "25.3.0-alpha7",
39
+ "@vaadin/chai-plugins": "25.3.0-alpha8",
40
+ "@vaadin/test-runner-commands": "25.3.0-alpha8",
41
41
  "@vaadin/testing-helpers": "^2.0.0",
42
42
  "sinon": "^22.0.0"
43
43
  },
44
44
  "customElements": "custom-elements.json",
45
- "gitHead": "ae7b9823df5598faebd7a482993029ee489c35ae"
45
+ "gitHead": "ccbb4aaffb63c745c6da0426b532d4d05e47af29"
46
46
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2000 - 2026 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ /**
8
+ * Adds the element to the target's `ariaDescribedByElements` or
9
+ * `ariaLabelledByElements` property, based on the given attribute.
10
+ * Unlike ID references, element references also work across shadow roots.
11
+ */
12
+ export function addAriaElementReference(
13
+ target: HTMLElement,
14
+ attr: 'aria-describedby' | 'aria-labelledby',
15
+ element: HTMLElement,
16
+ ): void;
17
+
18
+ /**
19
+ * Removes the element from the target's `ariaDescribedByElements` or
20
+ * `ariaLabelledByElements` property, based on the given attribute.
21
+ * When the last element is removed, the property is reset to `null`
22
+ * so it no longer overrides the content attribute.
23
+ */
24
+ export function removeAriaElementReference(
25
+ target: HTMLElement,
26
+ attr: 'aria-describedby' | 'aria-labelledby',
27
+ element: HTMLElement,
28
+ ): void;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2000 - 2026 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ const ARIA_REFERENCE_PROPERTIES = {
8
+ 'aria-describedby': 'ariaDescribedByElements',
9
+ 'aria-labelledby': 'ariaLabelledByElements',
10
+ };
11
+
12
+ /**
13
+ * Adds the element to the target's `ariaDescribedByElements` or
14
+ * `ariaLabelledByElements` property, based on the given attribute.
15
+ * Unlike ID references, element references also work across shadow roots.
16
+ *
17
+ * @param {HTMLElement} target
18
+ * @param {'aria-describedby' | 'aria-labelledby'} attr
19
+ * @param {HTMLElement} element
20
+ */
21
+ export function addAriaElementReference(target, attr, element) {
22
+ const property = ARIA_REFERENCE_PROPERTIES[attr];
23
+ const elements = new Set(target[property]);
24
+ elements.add(element);
25
+ target[property] = [...elements];
26
+ }
27
+
28
+ /**
29
+ * Removes the element from the target's `ariaDescribedByElements` or
30
+ * `ariaLabelledByElements` property, based on the given attribute.
31
+ * When the last element is removed, the property is reset to `null`
32
+ * so it no longer overrides the content attribute.
33
+ *
34
+ * @param {HTMLElement} target
35
+ * @param {'aria-describedby' | 'aria-labelledby'} attr
36
+ * @param {HTMLElement} element
37
+ */
38
+ export function removeAriaElementReference(target, attr, element) {
39
+ const property = ARIA_REFERENCE_PROPERTIES[attr];
40
+ const elements = new Set(target[property]);
41
+ elements.delete(element);
42
+ target[property] = elements.size > 0 ? [...elements] : null;
43
+ }