From: jenkins-bot Date: Fri, 25 Mar 2016 13:55:42 +0000 (+0000) Subject: Merge "mediawiki.widgets: Remove use of bind() for lexical 'this' binding" X-Git-Tag: 1.31.0-rc.0~7507 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=1c80fe572eec7610f35c87e0a43e49d886193d58;hp=e12e5aa9aa7e8dbf64f559bf7c202f984e4e78ff Merge "mediawiki.widgets: Remove use of bind() for lexical 'this' binding" --- diff --git a/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js index 5369d35e71..58115c3140 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js @@ -25,23 +25,24 @@ * @private */ PageExistenceCache.prototype.processExistenceCheckQueue = function () { - var queue, titles; + var queue, titles, + cache = this; if ( this.currentRequest ) { // Don't fire off a million requests at the same time this.currentRequest.always( function () { - this.currentRequest = null; - this.processExistenceCheckQueueDebounced(); - }.bind( this ) ); + cache.currentRequest = null; + cache.processExistenceCheckQueueDebounced(); + } ); return; } queue = this.existenceCheckQueue; this.existenceCheckQueue = {}; titles = Object.keys( queue ).filter( function ( title ) { - if ( this.existenceCache.hasOwnProperty( title ) ) { - queue[ title ].resolve( this.existenceCache[ title ] ); + if ( cache.existenceCache.hasOwnProperty( title ) ) { + queue[ title ].resolve( cache.existenceCache[ title ] ); } - return !this.existenceCache.hasOwnProperty( title ); - }.bind( this ) ); + return !cache.existenceCache.hasOwnProperty( title ); + } ); if ( !titles.length ) { return; } @@ -53,10 +54,10 @@ } ).done( function ( response ) { $.each( response.query.pages, function ( index, page ) { var title = new ForeignTitle( page.title ).getPrefixedText(); - this.existenceCache[ title ] = !page.missing; - queue[ title ].resolve( this.existenceCache[ title ] ); - }.bind( this ) ); - }.bind( this ) ); + cache.existenceCache[ title ] = !page.missing; + queue[ title ].resolve( cache.existenceCache[ title ] ); + } ); + } ); }; /** @@ -107,6 +108,7 @@ * @cfg {string} [apiUrl] API URL, if not the current wiki's API */ mw.widgets.CategoryCapsuleItemWidget = function MWWCategoryCapsuleItemWidget( config ) { + var widget = this; // Parent constructor mw.widgets.CategoryCapsuleItemWidget.parent.call( this, $.extend( { data: config.title.getMainText(), @@ -137,8 +139,8 @@ this.constructor.static.pageExistenceCaches[ this.apiUrl ] .checkPageExistence( new ForeignTitle( this.title.getPrefixedText() ) ) .done( function ( exists ) { - this.setMissing( !exists ); - }.bind( this ) ); + widget.setMissing( !exists ); + } ); /*jshint +W024*/ };