mediawiki-skins-Vector/resources/skins.vector.js/tables.js
Jon Robson caa650a881 Limit responsive tables to .wikitables
Bug: T330527
Change-Id: I61280270c6257ceaf5a6d74bb01be37063474bc7
2024-05-28 16:27:16 -07:00

22 lines
551 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 && 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
};