mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +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:
@@ -695,7 +695,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
|
||||
let element: Element = this.svgGroup_;
|
||||
while (element) {
|
||||
const classes = element.getAttribute('class') || '';
|
||||
if ((' ' + classes + ' ').indexOf(' injectionDiv ') !== -1) {
|
||||
if ((' ' + classes + ' ').includes(' injectionDiv ')) {
|
||||
this.injectionDiv = element;
|
||||
break;
|
||||
}
|
||||
@@ -1306,7 +1306,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
|
||||
// Using Set here would be great, but at the cost of IE10 support.
|
||||
if (!state) {
|
||||
arrayUtils.removeElem(this.highlightedBlocks, block);
|
||||
} else if (this.highlightedBlocks.indexOf(block) === -1) {
|
||||
} else if (!this.highlightedBlocks.includes(block)) {
|
||||
this.highlightedBlocks.push(block);
|
||||
}
|
||||
block.setHighlighted(state);
|
||||
|
||||
Reference in New Issue
Block a user