From 1ccb5be4c3ca39f0f3917a103c59849c99ebd915 Mon Sep 17 00:00:00 2001 From: bwang Date: Thu, 26 Sep 2024 17:00:51 -0500 Subject: [PATCH] Add logging to table wrapping experiment Bug: T374493 Change-Id: I276a58635504cfb30c3bcdec93f6bb29f5df730b --- resources/skins.vector.js/tables.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/resources/skins.vector.js/tables.js b/resources/skins.vector.js/tables.js index fdc824cbd..65d6644f0 100644 --- a/resources/skins.vector.js/tables.js +++ b/resources/skins.vector.js/tables.js @@ -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 = {