Merge "CodeMirrorPanel: specify type="button" for ToggleButton"

This commit is contained in:
jenkins-bot 2024-12-10 03:16:52 +00:00 committed by Gerrit Code Review
commit c3689196ad
2 changed files with 3 additions and 0 deletions

View file

@ -167,6 +167,7 @@ class CodeMirrorPanel {
// * cdx-toggle-button--toggled-off
btn.className = 'cdx-toggle-button cdx-toggle-button--framed ' +
`cdx-toggle-button--toggled-${ checked ? 'on' : 'off' } cm-mw-panel--toggle-button`;
btn.type = 'button';
btn.dataset.checked = String( checked );
btn.setAttribute( 'aria-pressed', checked );
// The following messages may be used here:

View file

@ -75,6 +75,7 @@ describe( 'CodeMirrorPanel', () => {
expect( toggleButtonOn.className ).toBe(
'cdx-toggle-button cdx-toggle-button--framed cdx-toggle-button--toggled-on cm-mw-panel--toggle-button'
);
expect( toggleButtonOn.type ).toBe( 'button' );
expect( toggleButtonOn.dataset.checked ).toBe( 'true' );
expect( toggleButtonOn.getAttribute( 'aria-pressed' ) ).toBe( 'true' );
expect( toggleButtonOn.title ).toBe( 'bar' );
@ -88,6 +89,7 @@ describe( 'CodeMirrorPanel', () => {
expect( toggleButtonOff.className ).toBe(
'cdx-toggle-button cdx-toggle-button--framed cdx-toggle-button--toggled-off cm-mw-panel--toggle-button'
);
expect( toggleButtonOff.type ).toBe( 'button' );
expect( toggleButtonOff.dataset.checked ).toBe( 'false' );
expect( toggleButtonOff.getAttribute( 'aria-pressed' ) ).toBe( 'false' );
} );