mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Merge pull request #446 from magmaboat/hasownproperty
Perform hasOwnProperty validation
This commit is contained in:
commit
a56db95aba
6 changed files with 16 additions and 2 deletions
|
@ -193,6 +193,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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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') &&
|
||||
|
@ -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') &&
|
||||
|
@ -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) {
|
||||
|
@ -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') {
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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?
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue