From 282b23f839341854969f3325fb558d7747895054 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 22 Feb 2022 23:35:25 +0000 Subject: [PATCH] fix: use new.target instead of a new parameter --- core/block.js | 6 ++---- core/block_svg.js | 2 +- scripts/gulpfiles/chunks.json | 18 +++++++++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/core/block.js b/core/block.js index d5d213801ff..2c6ef3ef9cc 100644 --- a/core/block.js +++ b/core/block.js @@ -75,12 +75,10 @@ class Block { * type-specific functions for this block. * @param {string=} opt_id Optional ID. Use this ID if provided, otherwise * create a new ID. - * @param {boolean=} opt_skipInit If true will not call init() on the block, - * so that the subclass can do that instead. * @throws When the prototypeName is not valid or not allowed. * @alias Blockly.Block */ - constructor(workspace, prototypeName, opt_id, opt_skipInit) { + constructor(workspace, prototypeName, opt_id) { const {Generator} = goog.module.get('Blockly.Generator'); if (Generator && typeof Generator.prototype[prototypeName] !== 'undefined') { @@ -361,7 +359,7 @@ class Block { workspace.addTopBlock(this); workspace.addTypedBlock(this); - if (!opt_skipInit) this.doInit_(); + if (new.target === Block) this.doInit_(); } /** diff --git a/core/block_svg.js b/core/block_svg.js index aaf6b505e29..5ec580b4d37 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -99,7 +99,7 @@ class BlockSvg extends Block { * @alias Blockly.BlockSvg */ constructor(workspace, prototypeName, opt_id) { - super(workspace, prototypeName, opt_id, true); + super(workspace, prototypeName, opt_id); /** * An optional method called when a mutator dialog is first opened. diff --git a/scripts/gulpfiles/chunks.json b/scripts/gulpfiles/chunks.json index f817e0af863..4558e7bfb08 100644 --- a/scripts/gulpfiles/chunks.json +++ b/scripts/gulpfiles/chunks.json @@ -80,11 +80,9 @@ "./core/utils/math.js", "./core/utils/array.js", "./core/workspace.js", - "./core/events/events_block_delete.js", "./core/keyboard_nav/basic_cursor.js", "./core/keyboard_nav/tab_navigate_cursor.js", "./core/warning.js", - "./core/events/events_bubble_open.js", "./core/comment.js", "./core/events/events_block_drag.js", "./core/events/events_block_move.js", @@ -99,21 +97,22 @@ "./core/zoom_controls.js", "./core/workspace_drag_surface_svg.js", "./core/events/events_selected.js", - "./core/events/events_comment_move.js", - "./core/events/events_comment_delete.js", - "./core/events/events_comment_create.js", - "./core/events/events_comment_base.js", - "./core/events/events_comment_change.js", - "./core/workspace_comment.js", "./core/interfaces/i_movable.js", "./core/interfaces/i_selectable.js", "./core/interfaces/i_copyable.js", + "./core/events/events_comment_delete.js", + "./core/events/events_comment_change.js", + "./core/workspace_comment.js", + "./core/events/events_comment_create.js", + "./core/events/events_comment_base.js", + "./core/events/events_comment_move.js", "./core/workspace_comment_svg.js", "./core/workspace_audio.js", "./core/events/events_trashcan_open.js", "./core/sprites.js", "./core/drag_target.js", "./core/delete_area.js", + "./core/events/events_block_delete.js", "./core/positionable_helpers.js", "./core/trashcan.js", "./core/touch_gesture.js", @@ -197,7 +196,6 @@ "./core/events/events_var_delete.js", "./core/variable_map.js", "./core/names.js", - "./core/events/events_ui_base.js", "./core/events/events_marker_move.js", "./core/renderers/common/marker_svg.js", "./core/keyboard_nav/marker.js", @@ -226,6 +224,8 @@ "./core/utils/svg_paths.js", "./core/renderers/common/constants.js", "./core/field.js", + "./core/events/events_ui_base.js", + "./core/events/events_bubble_open.js", "./core/procedures.js", "./core/workspace_svg.js", "./core/utils/rect.js",