Skip to content

Commit

Permalink
Merge pull request #5205 from ckeditor/t/5200
Browse files Browse the repository at this point in the history
Fix manual test: `plugins/button/manual/togglebuttons`
  • Loading branch information
jacekbogdanski authored May 12, 2022
2 parents e0253e0 + 2eb9b5c commit b6a5497
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tests/plugins/button/manual/togglebuttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@
<div id="editor">
<p>Whatever</p>
</div>
<table border="1">
<thead>
<tr>
<th scope="col">Button</th>
<th scope="col"><code>[aria-pressed]</code> value</th>
</tr>
</thead>
<tbody id="states"></tbody>
</table>

<div id="table"></div>
<script>
( function() {
CKEDITOR.replace( 'editor', {
Expand Down Expand Up @@ -55,15 +46,26 @@

function renderButtonStates() {
var buttons = CKEDITOR.document.find( '.cke_toolbar .cke_button' ).toArray(),
statesContainer = CKEDITOR.document.getById( 'states' ),
tableContainer = CKEDITOR.document.getById( 'table' ),
// Create the entire table in JS (#5200).
tableHtml = '<table border="1">' +
'<thead>' +
'<tr>' +
'<th scope="col">Button</th>' +
'<th scope="col"><code>[aria-pressed]</code> value</th>' +
'</tr>' +
'</thead>' +
'<tbody>{states}</tbody>' +
'</table>',
statesHtml = CKEDITOR.tools.array.map( buttons, function( button ) {
var currentState = button.getAttribute( 'aria-pressed' ),
buttonLabel = button.findOne( '.cke_button_label' ).getHtml();

return '<tr><th scope="row">' + buttonLabel + '</th><td>' + currentState + '</td></tr>';
} ).join( '' );

statesContainer.setHtml( statesHtml );
tableHtml = tableHtml.replace( '{states}', statesHtml );
tableContainer.setHtml( tableHtml );
}
} )();
</script>

0 comments on commit b6a5497

Please sign in to comment.