Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ab544a

Browse files
thiemowmdejenkins-bot
authored and
jenkins-bot
committed
Replace short anonymous functions with the arrow syntax
Note that the `this.` keyword behaves different in the new arrowsyntax. I think this is not a problem in any of these cases. Thecode is much shorter and hopefully faster and easier to read.Change-Id: Ib0684cb2e5e98d41a48804e2e18506f382b2bce6
1 parent8dddaeb commit2ab544a

15 files changed

+47
-123
lines changed

‎collab/ve.dm.CollabTransportServer.js‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ ve.dm.CollabTransportServer = function VeDmCollabTransportServer( startHeight )
2020
startHeight,
2121
// The server ID is arbitrary
2222
serverId:'ve-collab-server',
23-
load:function(){
24-
returnPromise.resolve(
25-
ve.dm.Change.static.deserialize({transactions:[]})
26-
);
27-
},
28-
onNewChange:function(){
29-
returnPromise.resolve();
30-
}
23+
load:()=>Promise.resolve(
24+
ve.dm.Change.static.deserialize({transactions:[]})
25+
),
26+
onNewChange:()=>Promise.resolve()
3127
},
3228
{
3329
/* eslint-disable-next-line no-console */

‎demos/ve/ve.demo.init.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,8 @@ new ve.init.sa.Platform( ve.messagePaths ).getInitializedPromise().then( () => {
107107
target.$element.attr('lang',currentLang);
108108

109109
// HACK: Override/restore message functions for qqx mode
110-
if(lang==='qqx'){
111-
ve.init.platform.getMessage=function(key){
112-
returnkey;
113-
};
114-
}else{
115-
ve.init.platform.getMessage=ve.init.sa.Platform.prototype.getMessage;
116-
}
110+
ve.init.platform.getMessage=lang==='qqx' ?(key)=>key :
111+
ve.init.sa.Platform.prototype.getMessage;
117112

118113
// Re-bind as getMessage may have changed
119114
OO.ui.msg=ve.init.platform.getMessage.bind(ve.init.platform);

‎src/ce/ve.ce.Document.js‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ ve.ce.Document.prototype.getSlugAtOffset = function ( offset ) {
106106
ve.ce.Document.prototype.getNodeAndOffset=function(offset){
107107
constcountedNodes=[];
108108

109-
// 1. Step with ve.adjacentDomPosition( …, { stop:function(){ returntrue; }} )
109+
// 1. Step with ve.adjacentDomPosition( …, { stop: ()=>true } )
110110
// until we hit a position at the correct offset (which is guaranteed to be the first
111111
// such position in document order).
112112
// 2. Use ve.adjacentDomPosition( …, { stop: … } ) once to return all
@@ -195,9 +195,7 @@ ve.ce.Document.prototype.getNodeAndOffset = function ( offset ) {
195195
1,
196196
{
197197
noDescend,
198-
stop:function(){
199-
returntrue;
200-
}
198+
stop:()=>true
201199
}
202200
);
203201
conststep=position.steps[0];

‎src/ce/ve.ce.Surface.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3468,9 +3468,7 @@ ve.ce.Surface.prototype.showSelectionState = function ( selection ) {
34683468
*@fires ve.dm.Surface#contextChange
34693469
*/
34703470
ve.ce.Surface.prototype.updateActiveAnnotations=function(fromModelOrNode){
3471-
constcanBeActive=function(view){
3472-
returnview.canBeActive();
3473-
};
3471+
constcanBeActive=(view)=>view.canBeActive();
34743472

34753473
letactiveAnnotations;
34763474
if(fromModelOrNode===true){

‎src/dm/ve.dm.Change.js‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,12 +898,9 @@ ve.dm.Change.prototype.serialize = function ( preserveStoreValues ) {
898898
for(constauthorIdinthis.selections){
899899
selections[authorId]=this.selections[authorId].toJSON();
900900
}
901-
constserializeStoreValues=preserveStoreValues ?functionnoop(x){
902-
returnx;
903-
} :this.constructor.static.serializeValue;
904-
constserializeStore=function(store){
905-
returnstore.serialize(serializeStoreValues);
906-
};
901+
constserializeStoreValues=preserveStoreValues ?(x)=>x :
902+
this.constructor.static.serializeValue;
903+
constserializeStore=(store)=>store.serialize(serializeStoreValues);
907904
letprevInfo;
908905
for(leti=0,iLen=this.transactions.length;i<iLen;i++){
909906
consttx=this.transactions[i];

‎src/ui/actions/ve.ui.TableAction.js‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ ve.ui.TableAction.prototype.deleteRowsOrColumns = function ( matrix, mode, minIn
10071007
*@param {ve.dm.TableMatrix} matrix Table matrix
10081008
*@param {ve.dm.TableMatrixCell} placeholder Placeholder cell to replace
10091009
*@param {Object} [options] Options to pass to ve.dm.TableCellNode.static.createData
1010-
*@return {Function} Zero-argument function returning a ve.dm.Transaction
1010+
*@return {Function} Zero-argument function returning a ve.dm.Transaction or null
10111011
*/
10121012
ve.ui.TableAction.prototype.replacePlaceholder=function(matrix,placeholder,options){
10131013
// For inserting the new cell a reference cell node
@@ -1021,9 +1021,7 @@ ve.ui.TableAction.prototype.replacePlaceholder = function ( matrix, placeholder,
10211021
}else{
10221022
constrowNode=matrix.getRowNode(placeholder.row);
10231023
if(!rowNode){
1024-
returnfunction(){
1025-
returnnull;
1026-
};
1024+
return()=>null;
10271025
}
10281026
// if there are only placeholders in the row, the row node's inner range is used
10291027
range=rowNode.getRange();

‎src/ve.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ ve.now = function () {
2222
// Optimisation: Avoid startup overhead by re-defining on first call instead of IIFE.
2323
constperf=window.performance;
2424
constnavStart=perf&&perf.timing&&perf.timing.navigationStart;
25-
ve.now=navStart&&perf.now ?
26-
function(){
27-
returnnavStart+perf.now();
28-
} :Date.now;
25+
ve.now=navStart&&perf.now ?()=>navStart+perf.now() :Date.now;
2926

3027
returnve.now();
3128
};

‎src/ve.utils.js‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ ve.isEqualDomElements = function ( domElements1, domElements2 ) {
266266
*@return {boolean} Class lists are equivalent
267267
*/
268268
ve.compareClassLists=function(classList1,classList2){
269-
constremoveEmpty=function(c){
270-
returnc!=='';
271-
};
269+
constremoveEmpty=(c)=>c;
272270

273271
classList1=Array.isArray(classList1) ?classList1 :classList1.trim().split(/\s+/);
274272
classList2=Array.isArray(classList2) ?classList2 :classList2.trim().split(/\s+/);
@@ -1267,9 +1265,7 @@ ve.rejectsCursor = function ( node ) {
12671265
*/
12681266
ve.countEdgeMatches=function(before,after,equals){
12691267
if(!equals){
1270-
equals=function(x,y){
1271-
returnx===y;
1272-
};
1268+
equals=(x,y)=>x===y;
12731269
}
12741270

12751271
letstart,end;

‎tests/ce/keydownhandlers/ve.ce.LinearEnterKeyDownHandler.test.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ QUnit.test( 'special key down: linear enter', ( assert ) => {
6161
keys:['ENTER'],
6262
htmlOrDoc:(()=>{
6363
constview=ve.test.utils.createSurfaceViewFromDocument(ve.dm.example.createExampleDocument());
64-
view.surface.isMultiline=function(){
65-
returnfalse;
66-
};
64+
view.surface.isMultiline=()=>false;
6765
returnview;
6866
})(),
6967
expectedData:noChange,

‎tests/ce/nodes/ve.ce.ResizableNode.test.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ QUnit.test( 'notResizable', ( assert ) => {
113113
isMobile=OO.ui.isMobile;
114114

115115
// Sizing is disabled on mobile:
116-
OO.ui.isMobile=function(){
117-
returntrue;
118-
};
116+
OO.ui.isMobile=()=>true;
119117

120118
assert.false(resizableNode.isResizable(),'Not resizable');
121119

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp