Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Make IPathObject styling methods optional #8332

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading