From: Timo Tijhof Date: Tue, 9 Apr 2019 03:14:48 +0000 (+0100) Subject: resourceloader: Simplify isCompatible() parameter in startup.js X-Git-Tag: 1.34.0-rc.0~2079^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres//%22%24url/%22?a=commitdiff_plain;h=5157ccb16af58c4a58ce01a22ba6d2e33935c52b;p=lhc%2Fweb%2Fwiklou.git resourceloader: Simplify isCompatible() parameter in startup.js This is a private function (now marked as such) only ever called once in prod code (a few lines further down). It is exposed to testing as well, which is why it has a parameter. Call it with a parameter within startup.js as well, so that we can remove the default handling and use the function the same way in prod as the way we use it in tests. Change-Id: Ie9db60e417cca29f86cea20359e880cb1fa20197 --- diff --git a/resources/src/startup/startup.js b/resources/src/startup/startup.js index bebf4dcf4a..240757c396 100644 --- a/resources/src/startup/startup.js +++ b/resources/src/startup/startup.js @@ -44,11 +44,11 @@ * * Other browsers that pass the check are considered Grade X. * - * @param {string} [str] User agent, defaults to navigator.userAgent + * @private + * @param {string} ua User agent string * @return {boolean} User agent is compatible with MediaWiki JS */ -function isCompatible( str ) { - var ua = str || navigator.userAgent; +function isCompatible( ua ) { return !!( // https://caniuse.com/#feat=es5 // https://caniuse.com/#feat=use-strict @@ -76,7 +76,7 @@ function isCompatible( str ) { ); } -if ( !isCompatible() ) { +if ( !isCompatible( navigator.userAgent ) ) { // Handle Grade C // Undo speculative Grade A class. See ResourceLoaderClientHtml::getDocumentAttributes(). document.documentElement.className = document.documentElement.className