Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/blocks/scratch3_sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ Scratch3SoundBlocks.prototype.changeEffect = function (args, util) {
Scratch3SoundBlocks.prototype.clearEffects = function (args, util) {
var soundState = this._getSoundState(util.target);
for (var effect in soundState.effects) {
if (!soundState.effects.hasOwnProperty(effect)) continue;
soundState.effects[effect] = 0;
}
if (util.target.audioPlayer === null) return;
Expand Down
1 change: 1 addition & 0 deletions src/engine/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var domToBlocks = function (blocksDOM) {
// Flatten blocks object into a list.
var blocksList = [];
for (var b in blocks) {
if (!blocks.hasOwnProperty(b)) continue;
blocksList.push(blocks[b]);
}
return blocksList;
Expand Down
4 changes: 4 additions & 0 deletions src/engine/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Blocks.prototype.getTopLevelScript = function (id) {
*/
Blocks.prototype.getProcedureDefinition = function (name) {
for (var id in this._blocks) {
if (!this._blocks.hasOwnProperty(id)) continue;
var block = this._blocks[id];
if ((block.opcode === 'procedures_defnoreturn' ||
block.opcode === 'procedures_defreturn') &&
Expand All @@ -166,6 +167,7 @@ Blocks.prototype.getProcedureDefinition = function (name) {
*/
Blocks.prototype.getProcedureParamNames = function (name) {
for (var id in this._blocks) {
if (!this._blocks.hasOwnProperty(id)) continue;
var block = this._blocks[id];
if ((block.opcode === 'procedures_defnoreturn' ||
block.opcode === 'procedures_defreturn') &&
Expand Down Expand Up @@ -415,6 +417,7 @@ Blocks.prototype.blockToXML = function (blockId) {
}
// Add any inputs on this block.
for (var input in block.inputs) {
if (!block.inputs.hasOwnProperty(input)) continue;
var blockInput = block.inputs[input];
// Only encode a value tag if the value input is occupied.
if (blockInput.block || blockInput.shadow) {
Expand All @@ -431,6 +434,7 @@ Blocks.prototype.blockToXML = function (blockId) {
}
// Add any fields on this block.
for (var field in block.fields) {
if (!block.fields.hasOwnProperty(field)) continue;
var blockField = block.fields[field];
var value = blockField.value;
if (typeof value === 'string') {
Expand Down
3 changes: 3 additions & 0 deletions src/engine/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ var execute = function (sequencer, thread) {
Object.keys(inputs).length === 0) {
// One field and no inputs - treat as arg.
for (var fieldKey in fields) { // One iteration.
if (!fields.hasOwnProperty(fieldKey)) continue;
handleReport(fields[fieldKey].value);
}
} else {
Expand All @@ -126,11 +127,13 @@ var execute = function (sequencer, thread) {

// Add all fields on this block to the argValues.
for (var fieldName in fields) {
if (!fields.hasOwnProperty(fieldName)) continue;
argValues[fieldName] = fields[fieldName].value;
}

// Recursively evaluate input blocks.
for (var inputName in inputs) {
if (!inputs.hasOwnProperty(inputName)) continue;
var input = inputs[inputName];
var inputBlockId = input.block;
// Is there no value for this input waiting in the stack frame?
Expand Down
3 changes: 3 additions & 0 deletions src/engine/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ Runtime.prototype.startHats = function (requestedHatOpcode,
var newThreads = [];

for (var opts in optMatchFields) {
if (!optMatchFields.hasOwnProperty(opts)) continue;
optMatchFields[opts] = optMatchFields[opts].toUpperCase();
}

Expand All @@ -463,6 +464,7 @@ Runtime.prototype.startHats = function (requestedHatOpcode,
if (Object.keys(hatFields).length === 0) {
var hatInputs = target.blocks.getInputs(topBlockId);
for (var input in hatInputs) {
if (!hatInputs.hasOwnProperty(input)) continue;
var id = hatInputs[input].block;
var fields = target.blocks.getFields(id);
hatFields = Object.assign(fields, hatFields);
Expand Down Expand Up @@ -592,6 +594,7 @@ Runtime.prototype.stopAll = function () {
Runtime.prototype._step = function () {
// Find all edge-activated hats, and add them to threads to be evaluated.
for (var hatType in this._hats) {
if (!this._hats.hasOwnProperty(hatType)) continue;
var hat = this._hats[hatType];
if (hat.edgeActivated) {
this.startHats(hatType);
Expand Down
6 changes: 4 additions & 2 deletions src/sprites/rendered-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ RenderedTarget.prototype.setEffect = function (effectName, value) {
*/
RenderedTarget.prototype.clearEffects = function () {
for (var effectName in this.effects) {
if (!this.effects.hasOwnProperty(effectName)) continue;
this.effects[effectName] = 0;
}
if (this.renderer) {
Expand Down Expand Up @@ -434,8 +435,9 @@ RenderedTarget.prototype.updateAllDrawableProperties = function () {
costume.rotationCenterY / costume.bitmapResolution
]
};
for (var effectID in this.effects) {
props[effectID] = this.effects[effectID];
for (var effectName in this.effects) {
if (!this.effects.hasOwnProperty(effectName)) continue;
props[effectName] = this.effects[effectName];
}
this.renderer.updateDrawableProperties(this.drawableID, props);
if (this.visible) {
Expand Down