Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(field-*): Remove unneeded fieldRegistry.unregister calls #2454

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/block-dynamic-connection/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/block-plus-minus/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/block-shareable-procedures/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/block-test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/content-highlight/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/continuous-toolbox/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/cross-tab-copy-paste/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/dev-tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/disable-top-blocks/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/field-angle/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions plugins/field-angle/src/field_angle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,6 @@ export class FieldAngle extends Blockly.FieldNumber {

/** Register the field and any dependencies. */
export function registerFieldAngle() {
// Unregister legacy field_angle that was in core.
// TODO(#2194): Delete this once core Blockly no longer defines field_angle.
// If field_angle is not defined in core, this generates a console warning.
Blockly.fieldRegistry.unregister('field_angle');

Blockly.fieldRegistry.register('field_angle', FieldAngle);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/field-bitmap/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/field-colour-hsv-sliders/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/field-colour/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions plugins/field-colour/src/field_colour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,6 @@ FieldColour.prototype.DEFAULT_VALUE = '#ffffff';
* Register the field and any dependencies.
*/
export function registerFieldColour() {
// Unregister legacy field_colour that was in core.
// TODO(#2194): Delete this once core Blockly no longer defines field_colour.
// If field_colour is not defined in core, this generates a console warning.
Blockly.fieldRegistry.unregister('field_colour');

Blockly.fieldRegistry.register('field_colour', FieldColour);
}

Expand Down
30 changes: 0 additions & 30 deletions plugins/field-colour/test/blocks_test.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,32 +169,6 @@ const blockJson = {
},
};

/**
* Uninstall old blocks and generators, since they come pre-installed
* with Blockly.
* TODO(#2194): Delete this function and calls to it.
*/
function uninstallBlocks() {
delete Blockly.Blocks['colour_blend'];
delete Blockly.Blocks['colour_rgb'];
delete Blockly.Blocks['colour_random'];
delete Blockly.Blocks['colour_picker'];

const blockNames = [
'colour_blend',
'colour_rgb',
'colour_random',
'colour_picker',
];
blockNames.forEach((name) => {
delete javascriptGenerator.forBlock[name];
delete dartGenerator.forBlock[name];
delete luaGenerator.forBlock[name];
delete pythonGenerator.forBlock[name];
delete phpGenerator.forBlock[name];
});
}

/**
* Assert that the generated code matches the golden code for the specified
* language.
Expand All @@ -212,7 +186,6 @@ function checkResult(suffix, generated) {

suite('Colour Block Generators', function () {
suiteSetup(function () {
uninstallBlocks();
installAllBlocks({
javascript: javascriptGenerator,
dart: dartGenerator,
Expand Down Expand Up @@ -248,7 +221,4 @@ suite('Colour Block Generators', function () {
teardown(function () {
this.workspace.dispose();
});
suiteTeardown(function () {
uninstallBlocks();
});
});
26 changes: 0 additions & 26 deletions plugins/field-colour/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,31 +240,6 @@ const jsonToolbox = {
],
};

/**
* Uninstall the base colour blocks and their associated generators.
* TODO(#2194): remove this when those blocks are removed from the core library.
*/
function uninstallBlocks() {
delete Blockly.Blocks['colour_blend'];
delete Blockly.Blocks['colour_rgb'];
delete Blockly.Blocks['colour_random'];
delete Blockly.Blocks['colour_picker'];

const blockNames = [
'colour_blend',
'colour_rgb',
'colour_random',
'colour_picker',
];
blockNames.forEach((name) => {
delete javascriptGenerator.forBlock[name];
delete dartGenerator.forBlock[name];
delete luaGenerator.forBlock[name];
delete pythonGenerator.forBlock[name];
delete phpGenerator.forBlock[name];
});
}

/**
* Create a workspace.
*
Expand All @@ -281,7 +256,6 @@ function createWorkspace(
}

document.addEventListener('DOMContentLoaded', function () {
uninstallBlocks();
installColourBlocks({
javascript: javascriptGenerator,
dart: dartGenerator,
Expand Down
2 changes: 1 addition & 1 deletion plugins/field-date/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/field-dependent-dropdown/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/field-grid-dropdown/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/field-multilineinput/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions plugins/field-multilineinput/src/field_multilineinput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,6 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
* Register the field and any dependencies.
*/
export function registerFieldMultilineInput() {
// Unregister legacy field_multilinetext that was in core.
// TODO(2194): Delete this once core Blockly no longer defines
// field_multilinetext.
// If field_multilinetext is not defined in core,
// this generates a console warning.
Blockly.fieldRegistry.unregister('field_multilinetext');

Blockly.fieldRegistry.register('field_multilinetext', FieldMultilineInput);
}

Expand Down
20 changes: 0 additions & 20 deletions plugins/field-multilineinput/test/block_test.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {phpGenerator} from 'blockly/php';
import {pythonGenerator} from 'blockly/python';
import {luaGenerator} from 'blockly/lua';
import {installAllBlocks} from '../src/index';
import {BLOCK_NAME} from '../src/blocks/textMultiline';
import {assert} from 'chai';

const blockJson = {
Expand All @@ -39,21 +38,6 @@ const blockJson = {
},
};

/**
* Uninstall old blocks and generators, since they come pre-installed
* with Blockly.
* TODO(#2194): Delete this function and calls to it.
*/
function uninstallBlocks() {
delete Blockly.Blocks[BLOCK_NAME];

delete javascriptGenerator.forBlock[BLOCK_NAME];
delete dartGenerator.forBlock[BLOCK_NAME];
delete luaGenerator.forBlock[BLOCK_NAME];
delete pythonGenerator.forBlock[BLOCK_NAME];
delete phpGenerator.forBlock[BLOCK_NAME];
}

/**
* Assert that the generated code matches the golden code for the specified
* language.
Expand All @@ -72,7 +56,6 @@ function checkResult(suffix, generated) {
suite('Multiline Text Block Generators', function () {
suiteSetup(function () {
Blockly.setLocale(en);
uninstallBlocks();
installAllBlocks({
javascript: javascriptGenerator,
dart: dartGenerator,
Expand Down Expand Up @@ -108,7 +91,4 @@ suite('Multiline Text Block Generators', function () {
teardown(function () {
this.workspace.dispose();
});
suiteTeardown(function () {
uninstallBlocks();
});
});
14 changes: 0 additions & 14 deletions plugins/field-multilineinput/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,6 @@ const jsonToolbox = {
],
};

/**
* Uninstall the base multiline text block and its associated generators.
* TODO(#2194): remove this when those blocks are removed from the core library.
*/
function uninstallBlock() {
delete Blockly.Blocks['text_multiline'];
delete javascriptGenerator.forBlock['text_multiline'];
delete dartGenerator.forBlock['text_multiline'];
delete luaGenerator.forBlock['text_multiline'];
delete pythonGenerator.forBlock['text_multiline'];
delete phpGenerator.forBlock['text_multiline'];
}

/**
* Create a workspace.
*
Expand All @@ -215,7 +202,6 @@ function createWorkspace(
blocklyDiv: HTMLElement,
options: Blockly.BlocklyOptions,
): Blockly.WorkspaceSvg {
uninstallBlock();
textMultiline.installBlock({
javascript: javascriptGenerator,
dart: dartGenerator,
Expand Down
2 changes: 1 addition & 1 deletion plugins/field-slider/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/fixed-edges/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/keyboard-navigation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/modal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/scroll-options/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/shadow-block-converter/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/strict-connection-checker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/suggested-blocks/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/theme-dark/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/theme-deuteranopia/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/theme-highcontrast/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading