Skip to content

Commit

Permalink
fix: use new.target instead of a new parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Feb 22, 2022
1 parent daaf608 commit 282b23f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 2 additions & 4 deletions core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -361,7 +359,7 @@ class Block {
workspace.addTopBlock(this);
workspace.addTypedBlock(this);

if (!opt_skipInit) this.doInit_();
if (new.target === Block) this.doInit_();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions scripts/gulpfiles/chunks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 282b23f

Please sign in to comment.