mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Convert local functions to arrow functions and remove this
bindings
Change-Id: I7987de8737103a1fc568944496c4d707dde60bc3
This commit is contained in:
parent
d8e803818d
commit
a5de8d5653
|
@ -92,14 +92,13 @@
|
|||
var deferred = ve.createDeferred(),
|
||||
baseNodeClass = ve.dm.MWTransclusionNode;
|
||||
|
||||
var model = this;
|
||||
function insertNode( isInline, generatedContents ) {
|
||||
var insertNode = ( isInline, generatedContents ) => {
|
||||
var type = isInline ? baseNodeClass.static.inlineType : baseNodeClass.static.blockType,
|
||||
data = [
|
||||
{
|
||||
type: type,
|
||||
attributes: {
|
||||
mw: model.getPlainObject()
|
||||
mw: this.getPlainObject()
|
||||
}
|
||||
},
|
||||
{ type: '/' + type }
|
||||
|
@ -117,7 +116,7 @@
|
|||
surfaceFragment.insertContent( data );
|
||||
|
||||
deferred.resolve();
|
||||
}
|
||||
};
|
||||
|
||||
if ( forceType ) {
|
||||
insertNode( forceType === 'inline' );
|
||||
|
|
|
@ -144,15 +144,13 @@ ve.init.mw.ApiResponseCache.prototype.getRequestPromise = null;
|
|||
* @fires ve.init.mw.ApiResponseCache#add
|
||||
*/
|
||||
ve.init.mw.ApiResponseCache.prototype.processQueue = function () {
|
||||
var cache = this;
|
||||
|
||||
function rejectSubqueue( rejectQueue ) {
|
||||
var rejectSubqueue = ( rejectQueue ) => {
|
||||
for ( var i = 0, len = rejectQueue.length; i < len; i++ ) {
|
||||
cache.deferreds[ rejectQueue[ i ] ].reject();
|
||||
this.deferreds[ rejectQueue[ i ] ].reject();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function processResult( data ) {
|
||||
var processResult = ( data ) => {
|
||||
var mappedTitles = [],
|
||||
pages = ( data.query && data.query.pages ) || data.pages,
|
||||
processed = {};
|
||||
|
@ -165,7 +163,7 @@ ve.init.mw.ApiResponseCache.prototype.processQueue = function () {
|
|||
var page, processedPage;
|
||||
for ( var pageid in pages ) {
|
||||
page = pages[ pageid ];
|
||||
processedPage = cache.constructor.static.processPage( page );
|
||||
processedPage = this.constructor.static.processPage( page );
|
||||
if ( processedPage !== undefined ) {
|
||||
processed[ page.title ] = processedPage;
|
||||
}
|
||||
|
@ -180,9 +178,9 @@ ve.init.mw.ApiResponseCache.prototype.processQueue = function () {
|
|||
break;
|
||||
}
|
||||
}
|
||||
cache.set( processed );
|
||||
this.set( processed );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var queue = this.queue;
|
||||
this.queue = [];
|
||||
|
|
|
@ -135,12 +135,11 @@ ve.ui.MWWikitextStringTransferHandler.prototype.process = function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var handler = this;
|
||||
function failure() {
|
||||
var failure = () => {
|
||||
// There's no DTH fallback handling for failures, so just paste
|
||||
// the raw wikitext if things go wrong.
|
||||
handler.resolve( wikitext );
|
||||
}
|
||||
this.resolve( wikitext );
|
||||
};
|
||||
|
||||
// Convert wikitext to html using Parsoid.
|
||||
this.parsoidRequest = ve.init.target.parseWikitextFragment( wikitext, false, this.surface.getModel().getDocument() );
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWWikitextSurface = function VeUiMWWikitextSurface() {
|
||||
var surface = this;
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWWikitextSurface.super.apply( this, arguments );
|
||||
|
||||
|
@ -49,6 +47,11 @@ ve.ui.MWWikitextSurface = function VeUiMWWikitextSurface() {
|
|||
this.$textbox.textSelection( 'unregister' );
|
||||
}
|
||||
|
||||
// Note: Chainable methods (setContents/setSelection) must use
|
||||
// non-arrow functions that return this. We can't just return
|
||||
// this.$textbox either as the collection could be cloned.
|
||||
/* eslint es-x/no-arrow-functions: error */
|
||||
var surface = this;
|
||||
// Backwards support for the textSelection API
|
||||
this.$textbox.textSelection( 'register', {
|
||||
getContents: function () {
|
||||
|
@ -90,6 +93,7 @@ ve.ui.MWWikitextSurface = function VeUiMWWikitextSurface() {
|
|||
return this;
|
||||
}
|
||||
} );
|
||||
/* eslint es-x/no-arrow-functions: off */
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
|
|
@ -212,27 +212,24 @@ ve.ui.MWTemplateTitleInputWidget.prototype.addExactMatch = function ( response )
|
|||
* @param {number} pageId
|
||||
* @return {boolean}
|
||||
*/
|
||||
function containsPageId( pages, pageId ) {
|
||||
return pageId && pages.some( ( page ) => page.pageid === pageId );
|
||||
}
|
||||
var containsPageId = ( pages, pageId ) => pageId && pages.some( ( page ) => page.pageid === pageId );
|
||||
|
||||
var widget = this;
|
||||
/**
|
||||
* @param {ve.ui.MWTemplateTitleInputWidget.PageResponse[]} pages
|
||||
* @param {Object} [newPage]
|
||||
*/
|
||||
function unshiftPages( pages, newPage ) {
|
||||
var unshiftPages = ( pages, newPage ) => {
|
||||
pages.forEach( ( page ) => {
|
||||
page.index++;
|
||||
} );
|
||||
if ( newPage && newPage.title ) {
|
||||
newPage.index = 1;
|
||||
pages.unshift( newPage );
|
||||
if ( pages.length > widget.limit ) {
|
||||
pages.sort( ( a, b ) => a.index - b.index ).splice( widget.limit );
|
||||
if ( pages.length > this.limit ) {
|
||||
pages.sort( ( a, b ) => a.index - b.index ).splice( this.limit );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var i,
|
||||
matchingRedirects = response.query.pages.filter( ( page ) => page.redirecttitle && page.redirecttitle.toLowerCase() === lowerTitle );
|
||||
|
|
Loading…
Reference in a new issue