Skip to content

Commit

Permalink
fix: add compose and decompose to block (#6102)
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-fenichel committed Apr 22, 2022
1 parent 7eed6a6 commit 619ee66
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ class Block {
*/
this.getDeveloperVariables = undefined;

/**
* An optional function that reconfigures the block based on the contents of
* the mutator dialog.
* @type {undefined|?function(!Block):void}
*/
this.compose = undefined;

/**
* An optional function that populates the mutator's dialog with
* this block's components.
* @type {undefined|?function(!Workspace):!Block}
*/
this.decompose = undefined;

/** @type {string} */
this.id = (opt_id && !workspace.getBlockById(opt_id)) ?
opt_id :
Expand Down
6 changes: 3 additions & 3 deletions core/events/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ const filter = function(queueIn, forward) {
if (!event.isNull()) {
// Treat all UI events as the same type in hash table.
const eventType = event.isUiEvent ? UI : event.type;
// TODO(#5927): Ceck whether `blockId` exists before accessing it.
const blockId = /** @type {*} */ (event).blockId;
// TODO(#5927): Check whether `blockId` exists before accessing it.
const blockId = /** @type {?} */ (event).blockId;
const key = [eventType, blockId, event.workspaceId].join(' ');

const lastEntry = hash[key];
Expand Down Expand Up @@ -525,7 +525,7 @@ exports.getDescendantIds = getDescendantIds;
* @alias Blockly.Events.utils.fromJson
*/
const fromJson = function(json, workspace) {
const eventClass = get(json.type);
const eventClass = get(json['type']);
if (!eventClass) {
throw Error('Unknown event type.');
}
Expand Down

0 comments on commit 619ee66

Please sign in to comment.