mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Check specifically for number in optional property
This commit is contained in:
parent
837703d4ac
commit
1ebb736a2a
1 changed files with 6 additions and 6 deletions
|
@ -488,10 +488,10 @@ class RenderedTarget extends Target {
|
||||||
* @param {?int} index Index at which to add costume
|
* @param {?int} index Index at which to add costume
|
||||||
*/
|
*/
|
||||||
addCostume (costumeObject, index) {
|
addCostume (costumeObject, index) {
|
||||||
if (typeof index === 'undefined') {
|
if (typeof index === 'number' && !isNaN(index)) {
|
||||||
this.sprite.addCostumeAt(costumeObject, this.sprite.costumes.length);
|
|
||||||
} else {
|
|
||||||
this.sprite.addCostumeAt(costumeObject, index);
|
this.sprite.addCostumeAt(costumeObject, index);
|
||||||
|
} else {
|
||||||
|
this.sprite.addCostumeAt(costumeObject, this.sprite.costumes.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,10 +551,10 @@ class RenderedTarget extends Target {
|
||||||
addSound (soundObject, index) {
|
addSound (soundObject, index) {
|
||||||
const usedNames = this.sprite.sounds.map(sound => sound.name);
|
const usedNames = this.sprite.sounds.map(sound => sound.name);
|
||||||
soundObject.name = StringUtil.unusedName(soundObject.name, usedNames);
|
soundObject.name = StringUtil.unusedName(soundObject.name, usedNames);
|
||||||
if (typeof index === 'undefined') {
|
if (typeof index === 'number' && !isNaN(index)) {
|
||||||
this.sprite.sounds.push(soundObject);
|
|
||||||
} else {
|
|
||||||
this.sprite.sounds.splice(index, 0, soundObject);
|
this.sprite.sounds.splice(index, 0, soundObject);
|
||||||
|
} else {
|
||||||
|
this.sprite.sounds.push(soundObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue