From c1abe80b08802d84fc9b96405016cecd118b210b Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Thu, 29 Oct 2020 15:33:53 +0100 Subject: [PATCH] Minor code cleanups, e.g. utilizing arrow functions Change-Id: I56bcfa040553a96f018f22483f3f988c5639fc97 --- resources/dist/index.js | Bin 42812 -> 42787 bytes resources/dist/index.js.map.json | Bin 204927 -> 204832 bytes src/container.js | 2 +- src/instrumentation/eventLogging.js | 15 +++------------ .../referencePreview/referencePreview.js | 2 +- .../changeListeners/footerLink.test.js | 4 +--- .../instrumentation/eventLogging.test.js | 8 +------- tests/selenium/pageobjects/popups.page.js | 4 +--- 8 files changed, 8 insertions(+), 27 deletions(-) diff --git a/resources/dist/index.js b/resources/dist/index.js index aa3d21e3ad867d59122171840db659f313d0be79..c34ce9b1016cc384c9d888e334e7f29b9f24ea66 100644 GIT binary patch delta 78 zcmV-U0I~nP&H|&(04_!zMKv`_Fr7+@wk4GXsrhLNNb-8csd*_*sfo$?d77Ii&z-;t E01nhE_W%F@ diff --git a/resources/dist/index.js.map.json b/resources/dist/index.js.map.json index 334b260f8096c6a1d0008ed2ac4655008b307f56..f2b46c728319a777032b1ec24afdbdfff547ff31 100644 GIT binary patch delta 190 zcmex=fM>x0o(&=;ye0lRu8xlGI>C<4rp}YqOQIRmH#e842Rns2dWPkCfF%9%JajxA z9ldobogAHWoXniSf)-&q;f~Jf&N{hHj*c15mSHf_P)Em5XPs~lgUxS_oBe9nIK;SJ z;}Fv+-|1_a8QG`%+-4G;&MUwyAg!hrlNVDGQ&OIpmy%zumzP+UnVwjZU!Ha$jw hS(DG!)>c71tu!yWBr`uxefmLvM#=4W1eh1|0{{WPJ=*{P delta 237 zcmZ2*fam`Ko(&=;!aCVbj*h-1{yMIXj_x|aj?OtQlNC#%88bK6mZ%3iMLK#$VLIWC&e~2oxjtrV9XI>M zs-dZ1Yu7G)h;h60A*R#5Y?)~a8VZWjAI33>^0=0z=9T#5r>AG;rBAOHX4aI7$%`q8 zDN!uX%uC5H*UL*R%S=x!$uClrQdT#}ierw&p*y;+!9k-I3h Yq_ikcp`@rZb^1bfM#=590?do~0aTDo$N&HU diff --git a/src/container.js b/src/container.js index fd1a67f1b..bffdc7f80 100644 --- a/src/container.js +++ b/src/container.js @@ -83,7 +83,7 @@ export default function createContainer() { } if ( !Object.prototype.hasOwnProperty.call( cache, name ) ) { - cache[ name ] = factories[ name ]( this ); + cache[ name ] = factory( this ); } return cache[ name ]; diff --git a/src/instrumentation/eventLogging.js b/src/instrumentation/eventLogging.js index a8b2f2810..41aeb507a 100644 --- a/src/instrumentation/eventLogging.js +++ b/src/instrumentation/eventLogging.js @@ -23,16 +23,7 @@ export function isEnabled( user, config, window ) { return true; } - if ( !config.get( 'wgPopupsEventLogging' ) ) { - return false; - } - - if ( - !window.navigator || - typeof window.navigator.sendBeacon !== 'function' - ) { - return false; - } - - return true; + return config.get( 'wgPopupsEventLogging' ) && + window.navigator && + typeof window.navigator.sendBeacon === 'function'; } diff --git a/src/ui/templates/referencePreview/referencePreview.js b/src/ui/templates/referencePreview/referencePreview.js index e869cebf5..eabd45545 100644 --- a/src/ui/templates/referencePreview/referencePreview.js +++ b/src/ui/templates/referencePreview/referencePreview.js @@ -66,7 +66,7 @@ export function renderReferencePreview( } ); // We assume elements that benefit from being collapsible are to large for the popup - $el.find( '.mw-collapsible' ).replaceWith( () => $( '
' ) + $el.find( '.mw-collapsible' ).replaceWith( $( '
' ) .addClass( 'mwe-collapsible-placeholder' ) .append( $( '' ) diff --git a/tests/node-qunit/changeListeners/footerLink.test.js b/tests/node-qunit/changeListeners/footerLink.test.js index 9d9c0549d..f811100ce 100644 --- a/tests/node-qunit/changeListeners/footerLink.test.js +++ b/tests/node-qunit/changeListeners/footerLink.test.js @@ -32,9 +32,7 @@ QUnit.module( 'ext.popups/changeListeners/footerLink @integration', { this.footerLinkChangeListener( undefined, this.state ); }; - this.getLink = function () { - return this.$footer.find( 'li:last-child' ); - }; + this.getLink = () => this.$footer.find( 'li:last-child' ); }, afterEach() { this.$footer.remove(); diff --git a/tests/node-qunit/instrumentation/eventLogging.test.js b/tests/node-qunit/instrumentation/eventLogging.test.js index 74d2403ae..529e84b58 100644 --- a/tests/node-qunit/instrumentation/eventLogging.test.js +++ b/tests/node-qunit/instrumentation/eventLogging.test.js @@ -15,13 +15,7 @@ QUnit.module( 'ext.popups/instrumentation/eventLogging', { this.user = stubs.createStubUser(); // Helper function that DRYs up the tests below. - this.isEnabled = function () { - return isEnabled( - this.user, - this.config, - this.window - ); - }; + this.isEnabled = () => isEnabled( this.user, this.config, this.window ); } } ); diff --git a/tests/selenium/pageobjects/popups.page.js b/tests/selenium/pageobjects/popups.page.js index b91b3d788..3cd2e746d 100644 --- a/tests/selenium/pageobjects/popups.page.js +++ b/tests/selenium/pageobjects/popups.page.js @@ -59,9 +59,7 @@ class PopupsPage extends Page { } hasReferencePopupsEnabled() { - return browser.execute( function () { - return mw.config.get( 'wgPopupsReferencePreviews' ); - } ); + return browser.execute( () => mw.config.get( 'wgPopupsReferencePreviews' ) ); } abandonLink() {