mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-23 23:33:54 +00:00
Merge "Add logging to table wrapping experiment"
This commit is contained in:
commit
9bba83b53f
|
@ -4,6 +4,7 @@ const init = () => {
|
|||
return;
|
||||
}
|
||||
const tables = document.querySelectorAll( '.mw-parser-output table.wikitable' );
|
||||
let numberBigTables = 0;
|
||||
Array.from( tables ).forEach( ( table ) => {
|
||||
const styles = window.getComputedStyle( table );
|
||||
const isFloat = styles.getPropertyValue( 'float' ) === 'right' || styles.getPropertyValue( 'float' ) === 'left';
|
||||
|
@ -16,12 +17,25 @@ const init = () => {
|
|||
!parent.closest( 'table' ) &&
|
||||
!isFloat
|
||||
) {
|
||||
const tableRect = table.getBoundingClientRect();
|
||||
const tableWidth = tableRect && tableRect.width;
|
||||
const wrapper = document.createElement( 'div' );
|
||||
wrapper.classList.add( 'noresize' );
|
||||
parent.insertBefore( wrapper, table );
|
||||
wrapper.appendChild( table );
|
||||
|
||||
if ( tableWidth > 948 ) {
|
||||
numberBigTables++;
|
||||
}
|
||||
}
|
||||
} );
|
||||
if ( numberBigTables > 0 ) {
|
||||
// @ts-ignore
|
||||
mw.errorLogger.logError(
|
||||
new Error( `T374493: ${ numberBigTables } tables wrapped` ),
|
||||
'error.web-team'
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in a new issue