From c8d5ba1d5e19271f6eff498c20f95973df34de6a Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 15 Nov 2017 11:55:22 -0500 Subject: [PATCH] Delete block does nothing if the block doesnt exist --- src/engine/blocks.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index 11208bea9..fe6b11602 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -411,7 +411,8 @@ class Blocks { } /** - * Block management: delete blocks and their associated scripts. + * Block management: delete blocks and their associated scripts. Does nothing if a block + * with the given ID does not exist. * @param {!string} blockId Id of block to delete */ deleteBlock (blockId) { @@ -419,6 +420,10 @@ class Blocks { // Get block const block = this._blocks[blockId]; + if (!block) { + // No block with the given ID exists + return; + } // Delete children if (block.next !== null) {