mediawiki-skins-Vector/resources/skins.vector.js/tables.js
Bernard Wang 503559a05c Restrict table logic to nonfloated wikitables
Bug: T330527
Change-Id: I386a88481210f459d2174ff69e0f84d40fc9e3bd
2024-05-30 11:52:20 -05:00

26 lines
692 B
JavaScript

const config = require( './config.json' );
const init = () => {
if ( !config.VectorWrapTablesTemporary ) {
return;
}
const tables = document.querySelectorAll( '.mw-parser-output table.wikitable:not(.floatright):not(.floatleft)' );
Array.from( tables ).forEach( ( table ) => {
// Don't wrap tables within tables
const parent = table.parentElement;
if (
parent && table.matches( '.wikitable' ) &&
!parent.matches( '.noresize' ) &&
!parent.closest( 'table' )
) {
const wrapper = document.createElement( 'div' );
wrapper.classList.add( 'noresize' );
parent.insertBefore( wrapper, table );
wrapper.appendChild( table );
}
} );
};
module.exports = {
init
};