From e33b736171407390c1a53020f694c78d9bfd50cd Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Tue, 21 Sep 2021 21:16:18 +0100 Subject: [PATCH] refactor: Name default export of Blockly.blocks Use named exports in Blockly.blocks by giving the former default export the name 'definitions'. Part of #5153. --- blocks/lists.js | 18 ++++---- blocks/procedures.js | 84 +++++++++++++++++++++------------- blocks/text.js | 24 +++++----- core/block.js | 2 +- core/blockly.js | 8 ++-- core/blocks.js | 4 +- core/procedures.js | 6 +-- core/variables.js | 10 ++-- core/variables_dynamic.js | 4 +- scripts/migration/renamings.js | 1 + tests/deps.mocha.js | 4 +- tests/mocha/block_test.js | 3 +- tests/mocha/test_helpers.js | 7 +-- 13 files changed, 99 insertions(+), 76 deletions(-) diff --git a/blocks/lists.js b/blocks/lists.js index 33043da8662..17924bcba59 100644 --- a/blocks/lists.js +++ b/blocks/lists.js @@ -115,7 +115,7 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT } ]); // END JSON EXTRACT (Do not delete this comment.) -Blockly.blocks['lists_create_with'] = { +Blockly.blocks.definitions['lists_create_with'] = { /** * Block for creating a list with any number of elements of any type. * @this {Blockly.Block} @@ -259,7 +259,7 @@ Blockly.blocks['lists_create_with'] = { } }; -Blockly.blocks['lists_create_with_container'] = { +Blockly.blocks.definitions['lists_create_with_container'] = { /** * Mutator block for list container. * @this {Blockly.Block} @@ -274,7 +274,7 @@ Blockly.blocks['lists_create_with_container'] = { } }; -Blockly.blocks['lists_create_with_item'] = { +Blockly.blocks.definitions['lists_create_with_item'] = { /** * Mutator block for adding items. * @this {Blockly.Block} @@ -290,7 +290,7 @@ Blockly.blocks['lists_create_with_item'] = { } }; -Blockly.blocks['lists_indexOf'] = { +Blockly.blocks.definitions['lists_indexOf'] = { /** * Block for finding an item in the list. * @this {Blockly.Block} @@ -319,7 +319,7 @@ Blockly.blocks['lists_indexOf'] = { } }; -Blockly.blocks['lists_getIndex'] = { +Blockly.blocks.definitions['lists_getIndex'] = { /** * Block for getting element at index. * @this {Blockly.Block} @@ -510,7 +510,7 @@ Blockly.blocks['lists_getIndex'] = { } }; -Blockly.blocks['lists_setIndex'] = { +Blockly.blocks.definitions['lists_setIndex'] = { /** * Block for setting the element at index. * @this {Blockly.Block} @@ -656,7 +656,7 @@ Blockly.blocks['lists_setIndex'] = { } }; -Blockly.blocks['lists_getSublist'] = { +Blockly.blocks.definitions['lists_getSublist'] = { /** * Block for getting sublist. * @this {Blockly.Block} @@ -772,7 +772,7 @@ Blockly.blocks['lists_getSublist'] = { } }; -Blockly.blocks['lists_sort'] = { +Blockly.blocks.definitions['lists_sort'] = { /** * Block for sorting a list. * @this {Blockly.Block} @@ -812,7 +812,7 @@ Blockly.blocks['lists_sort'] = { } }; -Blockly.blocks['lists_split'] = { +Blockly.blocks.definitions['lists_split'] = { /** * Block for splitting text into a list, or joining a list into text. * @this {Blockly.Block} diff --git a/blocks/procedures.js b/blocks/procedures.js index 0900c6ba5bc..6e12fe2dbac 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -22,7 +22,7 @@ goog.require('Blockly.Mutator'); goog.require('Blockly.Warning'); -Blockly.blocks['procedures_defnoreturn'] = { +Blockly.blocks.definitions['procedures_defnoreturn'] = { /** * Block for defining a procedure with no return value. * @this {Blockly.Block} @@ -450,7 +450,7 @@ Blockly.blocks['procedures_defnoreturn'] = { callType_: 'procedures_callnoreturn' }; -Blockly.blocks['procedures_defreturn'] = { +Blockly.blocks.definitions['procedures_defreturn'] = { /** * Block for defining a procedure with a return value. * @this {Blockly.Block} @@ -482,12 +482,16 @@ Blockly.blocks['procedures_defreturn'] = { this.setStatements_(true); this.statementConnection_ = null; }, - setStatements_: Blockly.blocks['procedures_defnoreturn'].setStatements_, - updateParams_: Blockly.blocks['procedures_defnoreturn'].updateParams_, - mutationToDom: Blockly.blocks['procedures_defnoreturn'].mutationToDom, - domToMutation: Blockly.blocks['procedures_defnoreturn'].domToMutation, - decompose: Blockly.blocks['procedures_defnoreturn'].decompose, - compose: Blockly.blocks['procedures_defnoreturn'].compose, + setStatements_: + Blockly.blocks.definitions['procedures_defnoreturn'].setStatements_, + updateParams_: + Blockly.blocks.definitions['procedures_defnoreturn'].updateParams_, + mutationToDom: + Blockly.blocks.definitions['procedures_defnoreturn'].mutationToDom, + domToMutation: + Blockly.blocks.definitions['procedures_defnoreturn'].domToMutation, + decompose: Blockly.blocks.definitions['procedures_defnoreturn'].decompose, + compose: Blockly.blocks.definitions['procedures_defnoreturn'].compose, /** * Return the signature of this procedure definition. * @return {!Array} Tuple containing three elements: @@ -499,16 +503,21 @@ Blockly.blocks['procedures_defreturn'] = { getProcedureDef: function() { return [this.getFieldValue('NAME'), this.arguments_, true]; }, - getVars: Blockly.blocks['procedures_defnoreturn'].getVars, - getVarModels: Blockly.blocks['procedures_defnoreturn'].getVarModels, - renameVarById: Blockly.blocks['procedures_defnoreturn'].renameVarById, - updateVarName: Blockly.blocks['procedures_defnoreturn'].updateVarName, - displayRenamedVar_: Blockly.blocks['procedures_defnoreturn'].displayRenamedVar_, - customContextMenu: Blockly.blocks['procedures_defnoreturn'].customContextMenu, + getVars: Blockly.blocks.definitions['procedures_defnoreturn'].getVars, + getVarModels: + Blockly.blocks.definitions['procedures_defnoreturn'].getVarModels, + renameVarById: + Blockly.blocks.definitions['procedures_defnoreturn'].renameVarById, + updateVarName: + Blockly.blocks.definitions['procedures_defnoreturn'].updateVarName, + displayRenamedVar_: + Blockly.blocks.definitions['procedures_defnoreturn'].displayRenamedVar_, + customContextMenu: + Blockly.blocks.definitions['procedures_defnoreturn'].customContextMenu, callType_: 'procedures_callreturn' }; -Blockly.blocks['procedures_mutatorcontainer'] = { +Blockly.blocks.definitions['procedures_mutatorcontainer'] = { /** * Mutator block for procedure container. * @this {Blockly.Block} @@ -526,7 +535,7 @@ Blockly.blocks['procedures_mutatorcontainer'] = { }, }; -Blockly.blocks['procedures_mutatorarg'] = { +Blockly.blocks.definitions['procedures_mutatorarg'] = { /** * Mutator block for procedure argument. * @this {Blockly.Block} @@ -637,7 +646,7 @@ Blockly.blocks['procedures_mutatorarg'] = { } }; -Blockly.blocks['procedures_callnoreturn'] = { +Blockly.blocks.definitions['procedures_callnoreturn'] = { /** * Block for calling a procedure with no return value. * @this {Blockly.Block} @@ -1029,7 +1038,7 @@ Blockly.blocks['procedures_callnoreturn'] = { defType_: 'procedures_defnoreturn' }; -Blockly.blocks['procedures_callreturn'] = { +Blockly.blocks.definitions['procedures_callreturn'] = { /** * Block for calling a procedure with a return value. * @this {Blockly.Block} @@ -1048,24 +1057,33 @@ Blockly.blocks['procedures_callreturn'] = { this.previousEnabledState_ = true; }, - getProcedureCall: Blockly.blocks['procedures_callnoreturn'].getProcedureCall, - renameProcedure: Blockly.blocks['procedures_callnoreturn'].renameProcedure, + getProcedureCall: + Blockly.blocks.definitions['procedures_callnoreturn'].getProcedureCall, + renameProcedure: + Blockly.blocks.definitions['procedures_callnoreturn'].renameProcedure, setProcedureParameters_: - Blockly.blocks['procedures_callnoreturn'].setProcedureParameters_, - updateShape_: Blockly.blocks['procedures_callnoreturn'].updateShape_, - mutationToDom: Blockly.blocks['procedures_callnoreturn'].mutationToDom, - domToMutation: Blockly.blocks['procedures_callnoreturn'].domToMutation, - saveExtraState: Blockly.blocks['procedures_callnoreturn'].saveExtraState, - loadExtraState: Blockly.blocks['procedures_callnoreturn'].loadExtraState, - getVars: Blockly.blocks['procedures_callnoreturn'].getVars, - getVarModels: Blockly.blocks['procedures_callnoreturn'].getVarModels, - onchange: Blockly.blocks['procedures_callnoreturn'].onchange, + Blockly.blocks.definitions['procedures_callnoreturn'] + .setProcedureParameters_, + updateShape_: + Blockly.blocks.definitions['procedures_callnoreturn'].updateShape_, + mutationToDom: + Blockly.blocks.definitions['procedures_callnoreturn'].mutationToDom, + domToMutation: + Blockly.blocks.definitions['procedures_callnoreturn'].domToMutation, + saveExtraState: + Blockly.blocks.definitions['procedures_callnoreturn'].saveExtraState, + loadExtraState: + Blockly.blocks.definitions['procedures_callnoreturn'].loadExtraState, + getVars: Blockly.blocks.definitions['procedures_callnoreturn'].getVars, + getVarModels: + Blockly.blocks.definitions['procedures_callnoreturn'].getVarModels, + onchange: Blockly.blocks.definitions['procedures_callnoreturn'].onchange, customContextMenu: - Blockly.blocks['procedures_callnoreturn'].customContextMenu, + Blockly.blocks.definitions['procedures_callnoreturn'].customContextMenu, defType_: 'procedures_defreturn' }; -Blockly.blocks['procedures_ifreturn'] = { +Blockly.blocks.definitions['procedures_ifreturn'] = { /** * Block for conditionally returning a value from a procedure. * @this {Blockly.Block} @@ -1162,7 +1180,9 @@ Blockly.blocks['procedures_ifreturn'] = { /** * List of block types that are functions and thus do not need warnings. * To add a new function type add this to your code: - * Blockly.blocks['procedures_ifreturn'].FUNCTION_TYPES.push('custom_func'); + * + * Blockly.blocks.definitions['procedures_ifreturn'] + * .FUNCTION_TYPES.push('custom_func'); */ FUNCTION_TYPES: ['procedures_defnoreturn', 'procedures_defreturn'] }; diff --git a/blocks/text.js b/blocks/text.js index 23af2cc3a18..84b123ed7af 100644 --- a/blocks/text.js +++ b/blocks/text.js @@ -226,7 +226,7 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT } ]); // END JSON EXTRACT (Do not delete this comment.) -Blockly.blocks['text_getSubstring'] = { +Blockly.blocks.definitions['text_getSubstring'] = { /** * Block for getting substring. * @this {Blockly.Block} @@ -347,7 +347,7 @@ Blockly.blocks['text_getSubstring'] = { } }; -Blockly.blocks['text_changeCase'] = { +Blockly.blocks.definitions['text_changeCase'] = { /** * Block for changing capitalization. * @this {Blockly.Block} @@ -368,7 +368,7 @@ Blockly.blocks['text_changeCase'] = { } }; -Blockly.blocks['text_trim'] = { +Blockly.blocks.definitions['text_trim'] = { /** * Block for trimming spaces. * @this {Blockly.Block} @@ -389,7 +389,7 @@ Blockly.blocks['text_trim'] = { } }; -Blockly.blocks['text_print'] = { +Blockly.blocks.definitions['text_print'] = { /** * Block for print statement. * @this {Blockly.Block} @@ -412,7 +412,7 @@ Blockly.blocks['text_print'] = { } }; -Blockly.blocks['text_prompt_ext'] = { +Blockly.blocks.definitions['text_prompt_ext'] = { /** * Block for prompt function (external message). * @this {Blockly.Block} @@ -474,7 +474,7 @@ Blockly.blocks['text_prompt_ext'] = { // XML hooks are kept for backwards compatibility. }; -Blockly.blocks['text_prompt'] = { +Blockly.blocks.definitions['text_prompt'] = { /** * Block for prompt function (internal message). * The 'text_prompt_ext' block is preferred as it is more flexible. @@ -506,12 +506,12 @@ Blockly.blocks['text_prompt'] = { Blockly.Msg['TEXT_PROMPT_TOOLTIP_NUMBER']; }); }, - updateType_: Blockly.blocks['text_prompt_ext'].updateType_, - mutationToDom: Blockly.blocks['text_prompt_ext'].mutationToDom, - domToMutation: Blockly.blocks['text_prompt_ext'].domToMutation + updateType_: Blockly.blocks.definitions['text_prompt_ext'].updateType_, + mutationToDom: Blockly.blocks.definitions['text_prompt_ext'].mutationToDom, + domToMutation: Blockly.blocks.definitions['text_prompt_ext'].domToMutation }; -Blockly.blocks['text_count'] = { +Blockly.blocks.definitions['text_count'] = { /** * Block for counting how many times one string appears within another string. * @this {Blockly.Block} @@ -540,7 +540,7 @@ Blockly.blocks['text_count'] = { } }; -Blockly.blocks['text_replace'] = { +Blockly.blocks.definitions['text_replace'] = { /** * Block for replacing one string with another in the text. * @this {Blockly.Block} @@ -574,7 +574,7 @@ Blockly.blocks['text_replace'] = { } }; -Blockly.blocks['text_reverse'] = { +Blockly.blocks.definitions['text_reverse'] = { /** * Block for reversing a string. * @this {Blockly.Block} diff --git a/core/block.js b/core/block.js index ffcc0871164..4389adf9c4d 100644 --- a/core/block.js +++ b/core/block.js @@ -208,7 +208,7 @@ const Block = function(workspace, prototypeName, opt_id) { if (prototypeName) { /** @type {string} */ this.type = prototypeName; - const prototype = blocks[prototypeName]; + const prototype = blocks.definitions[prototypeName]; if (!prototype || typeof prototype != 'object') { throw TypeError('Unknown block type: ' + prototypeName); } diff --git a/core/blockly.js b/core/blockly.js index f448bf04d9d..fb67f89afbb 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -63,8 +63,8 @@ goog.require('Blockly.Xml'); // Reexports. -/** @deprecated Use Blockly.blocks instead. */ -exports.Blocks = blocks; +/** @deprecated Use Blockly.blocks.definitions instead. */ +exports.Blocks = blocks.definitions; /** * Blockly core version. @@ -246,12 +246,12 @@ const defineBlocksWithJsonArray = function(jsonArray) { 'Block definition #' + i + ' in JSON array is missing a type attribute. Skipping.'); } else { - if (blocks[typename]) { + if (blocks.definitions[typename]) { console.warn( 'Block definition #' + i + ' in JSON array' + ' overwrites prior definition of "' + typename + '".'); } - blocks[typename] = {init: jsonInitFactory(elem)}; + blocks.definitions[typename] = {init: jsonInitFactory(elem)}; } } } diff --git a/core/blocks.js b/core/blocks.js index b716b948e2e..038759a49ba 100644 --- a/core/blocks.js +++ b/core/blocks.js @@ -21,6 +21,6 @@ goog.module.declareLegacyNamespace(); * A mapping of block type names to block prototype objects. * @type {!Object} */ -const blocks = Object.create(null); +const definitions = Object.create(null); -exports = blocks; +exports.definitions = definitions; diff --git a/core/procedures.js b/core/procedures.js index a54102bcff1..598f68003d1 100644 --- a/core/procedures.js +++ b/core/procedures.js @@ -193,7 +193,7 @@ exports.rename = rename; */ const flyoutCategory = function(workspace) { const xmlList = []; - if (blocks['procedures_defnoreturn']) { + if (blocks.definitions['procedures_defnoreturn']) { // // do something // @@ -207,7 +207,7 @@ const flyoutCategory = function(workspace) { block.appendChild(nameField); xmlList.push(block); } - if (blocks['procedures_defreturn']) { + if (blocks.definitions['procedures_defreturn']) { // // do something // @@ -221,7 +221,7 @@ const flyoutCategory = function(workspace) { block.appendChild(nameField); xmlList.push(block); } - if (blocks['procedures_ifreturn']) { + if (blocks.definitions['procedures_ifreturn']) { // const block = utilsXml.createElement('block'); block.setAttribute('type', 'procedures_ifreturn'); diff --git a/core/variables.js b/core/variables.js index c3a06dad771..5f4c65c5b4e 100644 --- a/core/variables.js +++ b/core/variables.js @@ -140,17 +140,17 @@ const flyoutCategoryBlocks = function(workspace) { if (variableModelList.length > 0) { // New variables are added to the end of the variableModelList. const mostRecentVariable = variableModelList[variableModelList.length - 1]; - if (blocks['variables_set']) { + if (blocks.definitions['variables_set']) { const block = utilsXml.createElement('block'); block.setAttribute('type', 'variables_set'); - block.setAttribute('gap', blocks['math_change'] ? 8 : 24); + block.setAttribute('gap', blocks.definitions['math_change'] ? 8 : 24); block.appendChild(generateVariableFieldDom(mostRecentVariable)); xmlList.push(block); } - if (blocks['math_change']) { + if (blocks.definitions['math_change']) { const block = utilsXml.createElement('block'); block.setAttribute('type', 'math_change'); - block.setAttribute('gap', blocks['variables_get'] ? 20 : 8); + block.setAttribute('gap', blocks.definitions['variables_get'] ? 20 : 8); block.appendChild(generateVariableFieldDom(mostRecentVariable)); const value = Xml.textToDom( '' + @@ -162,7 +162,7 @@ const flyoutCategoryBlocks = function(workspace) { xmlList.push(block); } - if (blocks['variables_get']) { + if (blocks.definitions['variables_get']) { variableModelList.sort(VariableModel.compareByName); for (let i = 0, variable; (variable = variableModelList[i]); i++) { const block = utilsXml.createElement('block'); diff --git a/core/variables_dynamic.js b/core/variables_dynamic.js index b66441370e9..a87893cda65 100644 --- a/core/variables_dynamic.js +++ b/core/variables_dynamic.js @@ -86,7 +86,7 @@ const flyoutCategoryBlocks = function(workspace) { const xmlList = []; if (variableModelList.length > 0) { - if (blocks['variables_set_dynamic']) { + if (blocks.definitions['variables_set_dynamic']) { const firstVariable = variableModelList[variableModelList.length - 1]; const block = xml.createElement('block'); block.setAttribute('type', 'variables_set_dynamic'); @@ -94,7 +94,7 @@ const flyoutCategoryBlocks = function(workspace) { block.appendChild(Variables.generateVariableFieldDom(firstVariable)); xmlList.push(block); } - if (blocks['variables_get_dynamic']) { + if (blocks.definitions['variables_get_dynamic']) { variableModelList.sort(VariableModel.compareByName); for (let i = 0, variable; (variable = variableModelList[i]); i++) { const block = xml.createElement('block'); diff --git a/scripts/migration/renamings.js b/scripts/migration/renamings.js index 50e3c1eefb3..2e3e556bf6a 100644 --- a/scripts/migration/renamings.js +++ b/scripts/migration/renamings.js @@ -95,6 +95,7 @@ const renamings = { }, 'Blockly.Blocks': { module: 'Blockly.blocks', + export: 'definitions', // Previous default export now named. }, 'Blockly.ContextMenu': { exports: { diff --git a/tests/deps.mocha.js b/tests/deps.mocha.js index 3d3985fe4be..30a3f2d57ba 100644 --- a/tests/deps.mocha.js +++ b/tests/deps.mocha.js @@ -309,7 +309,7 @@ goog.addDependency('../../tests/mocha/astnode_test.js', ['Blockly.test.astNode'] goog.addDependency('../../tests/mocha/block_change_event_test.js', ['Blockly.test.blockChangeEvent'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/block_create_event_test.js', ['Blockly.test.blockCreateEvent'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/block_json_test.js', ['Blockly.test.blockJson'], [], {'lang': 'es5', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/block_test.js', ['Blockly.test.blocks'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/block_test.js', ['Blockly.test.blocks'], ['Blockly.blocks', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/comment_test.js', ['Blockly.test.comments'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/connection_checker_test.js', ['Blockly.test.connectionChecker'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/connection_db_test.js', ['Blockly.test.connectionDb'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); @@ -351,7 +351,7 @@ goog.addDependency('../../tests/mocha/registry_test.js', ['Blockly.test.registry goog.addDependency('../../tests/mocha/run_mocha_tests_in_browser.js', [], [], {'lang': 'es8'}); goog.addDependency('../../tests/mocha/serializer_test.js', ['Blockly.test.serialization'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/shortcut_registry_test.js', ['Blockly.test.shortcutRegistry'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/test_helpers.js', ['Blockly.test.helpers'], ['Blockly.utils.KeyCodes'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/test_helpers.js', ['Blockly.test.helpers'], ['Blockly.blocks', 'Blockly.utils.KeyCodes'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/theme_test.js', ['Blockly.test.theme'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/toolbox_helper.js', ['Blockly.test.toolboxHelpers'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/toolbox_test.js', ['Blockly.test.toolbox'], ['Blockly.test.helpers', 'Blockly.test.toolboxHelpers'], {'lang': 'es6', 'module': 'goog'}); diff --git a/tests/mocha/block_test.js b/tests/mocha/block_test.js index bb3718c2643..addd3d60d28 100644 --- a/tests/mocha/block_test.js +++ b/tests/mocha/block_test.js @@ -6,6 +6,7 @@ goog.module('Blockly.test.blocks'); +const blocks = goog.require('Blockly.blocks'); const {createDeprecationWarningStub, createRenderedBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); @@ -1988,7 +1989,7 @@ suite('Blocks', function() { // so we assert init was called to be safe. var initCalled = false; var recordUndoDuringInit; - Blockly.blocks['init_test_block'].init = function() { + blocks.definitions['init_test_block'].init = function() { initCalled = true; recordUndoDuringInit = Blockly.Events.getRecordUndo(); throw new Error(); diff --git a/tests/mocha/test_helpers.js b/tests/mocha/test_helpers.js index a91b590b083..eb6e3ec9217 100644 --- a/tests/mocha/test_helpers.js +++ b/tests/mocha/test_helpers.js @@ -7,6 +7,7 @@ goog.module('Blockly.test.helpers'); const KeyCodes = goog.require('Blockly.utils.KeyCodes'); +const blocks = goog.require('Blockly.blocks'); /** @@ -137,7 +138,7 @@ exports.addMessageToCleanup = addMessageToCleanup; /** * Adds block type to shared cleanup object so that it is cleaned from - * Blockly.blocks global in sharedTestTeardown. + * Blockly.blocks.definitions global in sharedTestTeardown. * @param {!Object} sharedCleanupObj The shared cleanup object created in * sharedTestSetup. * @param {string} blockType The block type to add to shared cleanup object. @@ -150,7 +151,7 @@ exports.addBlockTypeToCleanup = addBlockTypeToCleanup; /** * Wraps Blockly.defineBlocksWithJsonArray using stub in order to keep track of * block types passed in to method on shared cleanup object so they are cleaned - * from Blockly.blocks global in sharedTestTeardown. + * from Blockly.blocks.definitions global in sharedTestTeardown. * @param {!Object} sharedCleanupObj The shared cleanup object created in * sharedTestSetup. * @private @@ -252,7 +253,7 @@ function sharedTestTeardown() { var blockTypes = this.sharedCleanup.blockTypesCleanup_; for (let i = 0; i < blockTypes.length; i++) { - delete Blockly.blocks[blockTypes[i]]; + delete blocks.definitions[blockTypes[i]]; } var messages = this.sharedCleanup.messagesCleanup_; for (let i = 0; i < messages.length; i++) {