mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -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;
|
||||
stage.setCostume(selectedIndex);
|
||||
}
|
||||
} else if (!isNaN(requestedBackdrop) &&
|
||||
(typeof requestedBackdrop !== 'string' || /\d/g.test(requestedBackdrop))) {
|
||||
// Try to cast the string to a number (and treat it as a costume index)
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue