mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Don't overwrite hat block's fields
Due to a typo (I believe) we were overwriting a horizontal hat block's fields list when collecting hat block inputs. Now we collect inputs into a temporary object in this case.
This commit is contained in:
parent
ef3feca385
commit
96fa7315d5
1 changed files with 5 additions and 1 deletions
|
@ -409,6 +409,9 @@ class Runtime extends EventEmitter {
|
|||
const opcode = convertedBlock.json.type;
|
||||
categoryInfo.blocks.push(convertedBlock);
|
||||
this._primitives[opcode] = convertedBlock.info.func;
|
||||
if (blockInfo.blockType === BlockType.HAT) {
|
||||
this._hats[opcode] = {edgeActivated: true}; /** @TODO let extension specify this */
|
||||
}
|
||||
}
|
||||
|
||||
this.emit(Runtime.EXTENSION_ADDED, categoryInfo.blocks);
|
||||
|
@ -802,13 +805,14 @@ class Runtime extends EventEmitter {
|
|||
|
||||
// If no fields are present, check inputs (horizontal blocks)
|
||||
if (Object.keys(hatFields).length === 0) {
|
||||
hatFields = {}; // don't overwrite the block's actual fields list
|
||||
const hatInputs = blocks.getInputs(block);
|
||||
for (const input in hatInputs) {
|
||||
if (!hatInputs.hasOwnProperty(input)) continue;
|
||||
const id = hatInputs[input].block;
|
||||
const inpBlock = blocks.getBlock(id);
|
||||
const fields = blocks.getFields(inpBlock);
|
||||
hatFields = Object.assign(fields, hatFields);
|
||||
Object.assign(hatFields, fields);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue