feat(core): inherit float classes to table wrapper

So that table would have the correct float style
This commit is contained in:
alistair3149 2023-05-01 02:23:40 -04:00 committed by GitHub
parent ee90992a89
commit d1d49e62d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,13 +60,31 @@ function setupOverflowState( element ) {
* @return {void} * @return {void}
*/ */
function wrapTable( table ) { function wrapTable( table ) {
// Don't do anything if there is a nowrap class // Don't do anything if there is a nowrap class
if ( table.classList.contains( 'citizen-table-nowrap' ) ) { if ( table.classList.contains( 'citizen-table-nowrap' ) ) {
return; return;
} }
const wrapper = document.createElement( 'div' ); const wrapper = document.createElement( 'div' );
wrapper.classList.add( 'citizen-table-wrapper' );
// Some classes should be inherited from the table
// For example, float helper classes like floatleft and floatright
const inheritTableClass = () => {
const tableClasses = [
'floatleft',
'floatright'
];
tableClasses.forEach( ( tableClass ) => {
if ( table.classList.contains( tableClass ) ) {
wrapper.classList.add( tableClass );
table.classList.remove( tableClass );
}
} );
};
wrapper.classList.add( 'citizen-table-wrapper' );
inheritTableClass();
table.parentNode.insertBefore( wrapper, table ); table.parentNode.insertBefore( wrapper, table );
wrapper.appendChild( table ); wrapper.appendChild( table );