From 39c0d4d01671adbe1e3b9ee9ac59132f6e1d567a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 23 Nov 2018 20:45:19 +0100 Subject: [PATCH] mediawiki.special.apisandbox: Fix code for ES5 environments (IE 11) The method Array#findIndex was introduced in ES6 [1] and we still support browsers that only implement ES5, like Internet Explorer 11. [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex#Specifications Change-Id: Idaebef7c91f2683099ab4980833ed76f0e3b51eb --- .../mediawiki.special.apisandbox/apisandbox.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/resources/src/mediawiki.special.apisandbox/apisandbox.js b/resources/src/mediawiki.special.apisandbox/apisandbox.js index 9b00ea200e..52bcd30fc1 100644 --- a/resources/src/mediawiki.special.apisandbox/apisandbox.js +++ b/resources/src/mediawiki.special.apisandbox/apisandbox.js @@ -1617,7 +1617,7 @@ }; } ); doProcess = function ( placeholder, target ) { - var values, container, index, usedVars, done; + var values, container, index, usedVars, done, items, i; target = prefix + target; @@ -1648,13 +1648,13 @@ done = $.isEmptyObject( p.vars ); if ( done ) { container = Util.apiBool( p.info.deprecated ) ? that.deprecatedItemsFieldset : that.itemsFieldset; - // FIXME: ES6-ism - // eslint-disable-next-line no-restricted-properties - index = container.getItems().findIndex( function ( el ) { - return el.apiParamIndex !== undefined && el.apiParamIndex > p.info.index; - } ); - if ( index < 0 ) { - index = undefined; + items = container.getItems(); + index = undefined; + for ( i = 0; i < items.length; i++ ) { + if ( items[ i ].apiParamIndex !== undefined && items[ i ].apiParamIndex > p.info.index ) { + index = i; + break; + } } } values.forEach( function ( value ) { -- 2.20.1