mirror of
https://github.com/google/blockly.git
synced 2025-12-15 22:00:07 +01:00
chore: Use .includes and .startsWith, not .indexOf (#7936)
Easier to read than the diverse collection of `=== 0` and `!== -1` and `> -1` tests.
This commit is contained in:
@@ -227,7 +227,7 @@ const LISTS_CREATE_WITH = {
|
||||
// Disconnect any children that don't belong.
|
||||
for (let i = 0; i < this.itemCount_; i++) {
|
||||
const connection = this.getInput('ADD' + i)!.connection!.targetConnection;
|
||||
if (connection && connections.indexOf(connection) === -1) {
|
||||
if (connection && !connections.includes(connection)) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,7 +858,7 @@ const PROCEDURE_CALL_COMMON = {
|
||||
if (
|
||||
mutatorOpen &&
|
||||
connection &&
|
||||
paramIds.indexOf(this.quarkIds_[i]) === -1
|
||||
!paramIds.includes(this.quarkIds_[i])
|
||||
) {
|
||||
// This connection should no longer be attached to this block.
|
||||
connection.disconnect();
|
||||
@@ -1043,7 +1043,7 @@ const PROCEDURE_CALL_COMMON = {
|
||||
}
|
||||
if (
|
||||
event.type === Events.BLOCK_CREATE &&
|
||||
(event as BlockCreate).ids!.indexOf(this.id) !== -1
|
||||
(event as BlockCreate).ids!.includes(this.id)
|
||||
) {
|
||||
// Look for the case where a procedure call was created (usually through
|
||||
// paste) and there is no matching definition. In this case, create
|
||||
@@ -1288,7 +1288,7 @@ const PROCEDURES_IFRETURN = {
|
||||
// Is the block nested in a procedure?
|
||||
let block = this; // eslint-disable-line @typescript-eslint/no-this-alias
|
||||
do {
|
||||
if (this.FUNCTION_TYPES.indexOf(block.type) !== -1) {
|
||||
if (this.FUNCTION_TYPES.includes(block.type)) {
|
||||
legal = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -829,7 +829,7 @@ const JOIN_MUTATOR_MIXIN = {
|
||||
// Disconnect any children that don't belong.
|
||||
for (let i = 0; i < this.itemCount_; i++) {
|
||||
const connection = this.getInput('ADD' + i)!.connection!.targetConnection;
|
||||
if (connection && connections.indexOf(connection) === -1) {
|
||||
if (connection && !connections.includes(connection)) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user