mediawiki-skins-Vector/resources/skins.vector.js/tables.js
bwang e42b235669 Wrap tables with JS
Depends-on: Ia271a57776e6f38384c5855727ab82fd7af83241
Bug: T330527
Change-Id: I756f8e1bcd86867bee52962a0d1c2dbb34ca75eb
2024-05-24 15:49:54 -05:00

18 lines
505 B
JavaScript

const init = () => {
const tables = document.querySelectorAll( '.mw-parser-output table' );
Array.from( tables ).forEach( ( table ) => {
// Don't wrap tables within tables
const parent = table.parentElement;
if ( parent && !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
};