Skip to content

Commit fe3f83c

Browse files
committed
Merge branch 'staging/pfe5' into rename/all-elements
2 parents cbe3bd0 + 853c5f0 commit fe3f83c

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

.changeset/two-moose-cough.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
"@patternfly/pfe-core": patch
3+
---
4+
`InternalsController`: allows accessibility auditing tools to access element internals.

core/pfe-core/controllers/internals-controller.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ import {
44
type ReactiveControllerHost,
55
} from 'lit';
66

7-
function isARIAMixinProp(key: string): key is keyof ARIAMixin {
8-
return key === 'role' || key.startsWith('aria');
9-
}
10-
117
type FACE = HTMLElement & {
128
formDisabledCallback?(disabled: boolean): void;
139
};
1410

11+
interface InternalsControllerOptions extends Partial<ARIAMixin> {
12+
getHTMLElement?(): HTMLElement;
13+
}
14+
1515
const protos = new WeakMap();
1616

1717
let constructingAllowed = false;
1818

19-
interface InternalsControllerOptions extends Partial<ARIAMixin> {
20-
getHTMLElement?(): HTMLElement;
19+
globalThis._elementInternals ??= new WeakMap<Element, ElementInternals>();
20+
21+
function isARIAMixinProp(key: string): key is keyof ARIAMixin {
22+
return key === 'role' || key.startsWith('aria');
2123
}
2224

2325
/**
@@ -263,6 +265,8 @@ export class InternalsController implements ReactiveController, ARIAMixin {
263265
this.initializeOptions(options);
264266
InternalsController.instances.set(host, this);
265267
this.#polyfillDisabledPseudo();
268+
// Expose internals to aXe Core
269+
globalThis._elementInternals.set(this.host, this.internals);
266270
}
267271

268272
/**
@@ -335,6 +339,8 @@ export class InternalsController implements ReactiveController, ARIAMixin {
335339

336340
/** @see https://w3c.github.io/aria/#ref-for-dom-ariamixin-ariaactivedescendantelement-1 */
337341
declare global {
342+
// https://github.com/webcomponents-cg/community-protocols/pull/75
343+
var _elementInternals: WeakMap<Element, ElementInternals>; // eslint-disable-line no-var
338344
interface ARIAMixin {
339345
ariaActiveDescendantElement: Element | null;
340346
ariaControlsElements: readonly Element[] | null;

0 commit comments

Comments
 (0)