diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 831a40d5194..58bb350c161 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -1414,13 +1414,18 @@ class Runtime extends EventEmitter { if (!blockInfo.disableMonitor && context.inputList.length === 0) { blockJSON.checkboxInFlyout = true; } - } else if (blockInfo.blockType === BlockType.LOOP || blockInfo.branchIconURI) { + } else if ( + blockInfo.branchIconURI || ( + blockInfo.blockType === BlockType.LOOP && + !Object.prototype.hasOwnProperty.call(blockInfo, 'branchIconURI') + ) + ) { // Add icon to the bottom right of a loop block blockJSON[`lastDummyAlign${outLineNum}`] = 'RIGHT'; blockJSON[`message${outLineNum}`] = '%1'; blockJSON[`args${outLineNum}`] = [{ type: 'field_image', - src: blockInfo.branchIconURI || 'media://repeat.svg', + src: blockInfo.branchIconURI ?? 'media://repeat.svg', width: 24, height: 24, alt: '*', // TODO remove this since we don't use collapsed blocks in scratch diff --git a/test/unit/tw_branch_icon_uri.js b/test/unit/tw_branch_icon_uri.js index 0ad9316a824..f001039e85e 100644 --- a/test/unit/tw_branch_icon_uri.js +++ b/test/unit/tw_branch_icon_uri.js @@ -22,9 +22,15 @@ test('branchIconURI', t => { }, { blockType: BlockType.CONDITIONAL, - opcode: 'block2', + opcode: 'block3', text: 'CONDITIONAL with custom icon', branchIconURI: 'data:whatever2' + }, + { + blockType: BlockType.LOOP, + opcode: 'block4', + text: 'LOOP with no icon', + branchIconURI: '' } ] }) @@ -34,6 +40,7 @@ test('branchIconURI', t => { t.equal(blocks[0].args2[0].src, 'media://repeat.svg', 'default custom icon'); t.equal(blocks[1].args2[0].src, 'data:whatever1', 'LOOP with custom icon'); t.equal(blocks[2].args2[0].src, 'data:whatever2', 'CONDITIONAL with custom icon'); + t.same(blocks[3].args2, null, 'LOOP with no icon'); t.end(); });