mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 10:39:56 -05:00
refactor: use better whitespace-test for backdrops too
This commit is contained in:
parent
1a7ce093c3
commit
0c18b4952d
1 changed files with 4 additions and 2 deletions
|
@ -403,8 +403,10 @@ class Scratch3LooksBlocks {
|
||||||
if (selectedIndex === stage.currentCostume) selectedIndex += 1;
|
if (selectedIndex === stage.currentCostume) selectedIndex += 1;
|
||||||
stage.setCostume(selectedIndex);
|
stage.setCostume(selectedIndex);
|
||||||
}
|
}
|
||||||
} else if (!isNaN(requestedBackdrop) &&
|
// Try to cast the string to a number (and treat it as a costume index)
|
||||||
(typeof requestedBackdrop !== 'string' || /\d/g.test(requestedBackdrop))) {
|
// Pure whitespace should not be treated as a number (JS casts this to 0)
|
||||||
|
// Note: isNaN will cast the string to a number before checking if it's NaN
|
||||||
|
} else if (!(isNaN(requestedBackdrop) || Cast.isWhiteSpace(requestedBackdrop))) {
|
||||||
stage.setCostume(optZeroIndex ? Number(requestedBackdrop) : Number(requestedBackdrop) - 1);
|
stage.setCostume(optZeroIndex ? Number(requestedBackdrop) : Number(requestedBackdrop) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue