Skip to content

Commit

Permalink
fix!: Make IPathObject styling methods optional (#8332)
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatpathak98 authored Jul 12, 2024
1 parent 5a32c3f commit dd18edd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ export class BlockSvg
* @internal
*/
applyColour() {
this.pathObject.applyColour(this);
this.pathObject.applyColour?.(this);

const icons = this.getIcons();
for (let i = 0; i < icons.length; i++) {
Expand Down Expand Up @@ -1115,7 +1115,7 @@ export class BlockSvg
.getConstants()
.getBlockStyleForColour(this.colour_);

this.pathObject.setStyle(styleObj.style);
this.pathObject.setStyle?.(styleObj.style);
this.style = styleObj.style;
this.styleName_ = styleObj.name;

Expand All @@ -1137,7 +1137,7 @@ export class BlockSvg

if (blockStyle) {
this.hat = blockStyle.hat;
this.pathObject.setStyle(blockStyle);
this.pathObject.setStyle?.(blockStyle);
// Set colour to match Block.
this.colour_ = blockStyle.colourPrimary;
this.style = blockStyle;
Expand Down
30 changes: 15 additions & 15 deletions core/renderers/common/i_path_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ export interface IPathObject {
*/
setPath(pathString: string): void;

/**
* Apply the stored colours to the block's path, taking into account whether
* the paths belong to a shadow block.
*
* @param block The source block.
*/
applyColour(block: BlockSvg): void;

/**
* Update the style.
*
* @param blockStyle The block style to use.
*/
setStyle(blockStyle: BlockStyle): void;

/**
* Flip the SVG paths in RTL.
*/
Expand Down Expand Up @@ -130,8 +115,23 @@ export interface IPathObject {
rtl: boolean,
): void;

/**
* Apply the stored colours to the block's path, taking into account whether
* the paths belong to a shadow block.
*
* @param block The source block.
*/
applyColour?(block: BlockSvg): void;

/**
* Removes any highlight associated with the given connection, if it exists.
*/
removeConnectionHighlight?(connection: RenderedConnection): void;

/**
* Update the style.
*
* @param blockStyle The block style to use.
*/
setStyle?(blockStyle: BlockStyle): void;
}

0 comments on commit dd18edd

Please sign in to comment.