diff --git a/resources/codemirror.panel.js b/resources/codemirror.panel.js index 77978921..e78122b9 100644 --- a/resources/codemirror.panel.js +++ b/resources/codemirror.panel.js @@ -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: diff --git a/tests/jest/codemirror.panel.test.js b/tests/jest/codemirror.panel.test.js index 9bf4974c..91ede72c 100644 --- a/tests/jest/codemirror.panel.test.js +++ b/tests/jest/codemirror.panel.test.js @@ -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' ); } );