mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
refactor: Use arrow functions when calling Array.prototype.filter (#8557)
This commit is contained in:
committed by
GitHub
parent
a7afda8343
commit
724828f689
@@ -127,13 +127,8 @@ function fireNow() {
|
|||||||
const queue = filter(FIRE_QUEUE, true);
|
const queue = filter(FIRE_QUEUE, true);
|
||||||
FIRE_QUEUE.length = 0;
|
FIRE_QUEUE.length = 0;
|
||||||
for (const event of queue) {
|
for (const event of queue) {
|
||||||
if (!event.workspaceId) {
|
if (!event.workspaceId) continue;
|
||||||
continue;
|
common.getWorkspaceById(event.workspaceId)?.fireChangeListener(event);
|
||||||
}
|
|
||||||
const eventWorkspace = common.getWorkspaceById(event.workspaceId);
|
|
||||||
if (eventWorkspace) {
|
|
||||||
eventWorkspace.fireChangeListener(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -285,9 +285,9 @@ function hasCategoriesInternal(toolboxJson: ToolboxInfo | null): boolean {
|
|||||||
return toolboxKind === CATEGORY_TOOLBOX_KIND;
|
return toolboxKind === CATEGORY_TOOLBOX_KIND;
|
||||||
}
|
}
|
||||||
|
|
||||||
const categories = toolboxJson['contents'].filter(function (item) {
|
const categories = toolboxJson['contents'].filter(
|
||||||
return item['kind'].toUpperCase() === 'CATEGORY';
|
(item) => item['kind'].toUpperCase() === 'CATEGORY',
|
||||||
});
|
);
|
||||||
return !!categories.length;
|
return !!categories.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -255,9 +255,7 @@ export class Workspace implements IASTNodeLocation {
|
|||||||
blocks.sort(this.sortObjects_.bind(this));
|
blocks.sort(this.sortObjects_.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return blocks.filter(function (block: Block) {
|
return blocks.filter((block) => !block.isInsertionMarker());
|
||||||
return !block.isInsertionMarker();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,11 +339,7 @@ export class Workspace implements IASTNodeLocation {
|
|||||||
|
|
||||||
// Insertion markers exist on the workspace for rendering reasons, but
|
// Insertion markers exist on the workspace for rendering reasons, but
|
||||||
// aren't "real" blocks from a developer perspective.
|
// aren't "real" blocks from a developer perspective.
|
||||||
const filtered = blocks.filter(function (block) {
|
return blocks.filter((block) => !block.isInsertionMarker());
|
||||||
return !block.isInsertionMarker();
|
|
||||||
});
|
|
||||||
|
|
||||||
return filtered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dispose of all blocks and comments in workspace. */
|
/** Dispose of all blocks and comments in workspace. */
|
||||||
|
|||||||
@@ -543,9 +543,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
|
|||||||
|
|
||||||
// Update all blocks in workspace that have a style name.
|
// Update all blocks in workspace that have a style name.
|
||||||
this.updateBlockStyles_(
|
this.updateBlockStyles_(
|
||||||
this.getAllBlocks(false).filter(function (block) {
|
this.getAllBlocks(false).filter((block) => !!block.getStyleName()),
|
||||||
return !!block.getStyleName();
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update current toolbox selection.
|
// Update current toolbox selection.
|
||||||
|
|||||||
@@ -1745,9 +1745,9 @@ suite('Events', function () {
|
|||||||
// Fire all events
|
// Fire all events
|
||||||
this.clock.runAll();
|
this.clock.runAll();
|
||||||
|
|
||||||
const disabledEvents = this.workspace.getUndoStack().filter(function (e) {
|
const disabledEvents = this.workspace
|
||||||
return e.element === 'disabled';
|
.getUndoStack()
|
||||||
});
|
.filter((e) => e.element === 'disabled');
|
||||||
assert.isEmpty(
|
assert.isEmpty(
|
||||||
disabledEvents,
|
disabledEvents,
|
||||||
'Undo stack should not contain any disabled events',
|
'Undo stack should not contain any disabled events',
|
||||||
|
|||||||
Reference in New Issue
Block a user