Skip to content

Commit

Permalink
fix(field-*): Remove unneeded fieldRegistry.unregister calls (#2454)
Browse files Browse the repository at this point in the history
* fix(field-*): Remove unneeded fieldRegistry.unregister calls

  Since FieldAngle, FieldColour and FieldMultilineInput are no longer
  in core, there's no longer any need for their corresponding plugins
  to unregister the built-in version.

* chore(deps): Restore newlines in package-lock.json files

  For some reason the last time we ran publish, the publish commit
  7d3e23f removed all the trailing newlines from our
  package-lock.json files.

  In #2453 rachel-fenichel proposes adding these files to our
  .prettierignore.rc, but for now I'll just fix the files so that
  the format check passes.

* chore(field-*): Remove unneeded uninstallBlocks test helpers
  • Loading branch information
cpcallen authored Sep 26, 2024
1 parent 7a30c6c commit b3ba30e
Show file tree
Hide file tree
Showing 43 changed files with 36 additions and 143 deletions.
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

0 comments on commit b3ba30e

Please sign in to comment.