Update CheckboxHack interface for future placement of `aria-expanded` on label button

Currently, the `aria-expanded` attribute is placed on the checkbox
element. However, since Ife287fc8c6e0d2aee5facf42d5d4308dea918ee3, the
checkbox is excluded from the accessibility tree, and this attribute
should be placed on the label button instead.

This commit prepares for future changes [1] to the checkbox hack interface
in a backwards compatible way:

* Passes button to `updateAriaExpanded` function

* Passes button to `bindUpdateAriaExpandedOnInput` function

[1] Ia2755e189babbd70945b66a1a812fc3ece40b577

Change-Id: Icc6ba994d57ea1f8050aa408aebc8c81f03d8783
This commit is contained in:
Nicholas Ray 2020-06-29 13:23:48 -06:00
parent 91597ec441
commit b40c3f3743
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
interface CheckboxHack {
updateAriaExpanded(checkbox: HTMLInputElement): void;
bindUpdateAriaExpandedOnInput(checkbox: HTMLInputElement): CheckboxHackListeners;
updateAriaExpanded(checkbox: HTMLInputElement, button: HTMLElement): void;
bindUpdateAriaExpandedOnInput(checkbox: HTMLInputElement, button: HTMLElement): CheckboxHackListeners;
bindToggleOnClick(checkbox: HTMLInputElement, button: HTMLElement): CheckboxHackListeners;
bindDismissOnClickOutside(window: Window, checkbox: HTMLInputElement, button: HTMLElement, target: Node): CheckboxHackListeners;
bindDismissOnFocusLoss(window: Window, checkbox: HTMLInputElement, button: HTMLElement, target: Node): CheckboxHackListeners;

View File

@ -46,9 +46,9 @@ function initSidebar( document ) {
var button = document.getElementById( 'mw-sidebar-button' );
if ( checkbox instanceof HTMLInputElement && button ) {
checkboxHack.bindToggleOnClick( checkbox, button );
checkboxHack.bindUpdateAriaExpandedOnInput( checkbox );
checkboxHack.bindUpdateAriaExpandedOnInput( checkbox, button );
checkboxHack.updateAriaExpanded( checkbox );
checkboxHack.updateAriaExpanded( checkbox, button );
}
}