Skip to content

Commit dd18edd

Browse files
fix!: Make IPathObject styling methods optional (#8332)
1 parent 5a32c3f commit dd18edd

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

core/block_svg.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ export class BlockSvg
849849
* @internal
850850
*/
851851
applyColour() {
852-
this.pathObject.applyColour(this);
852+
this.pathObject.applyColour?.(this);
853853

854854
const icons = this.getIcons();
855855
for (let i = 0; i < icons.length; i++) {
@@ -1115,7 +1115,7 @@ export class BlockSvg
11151115
.getConstants()
11161116
.getBlockStyleForColour(this.colour_);
11171117

1118-
this.pathObject.setStyle(styleObj.style);
1118+
this.pathObject.setStyle?.(styleObj.style);
11191119
this.style = styleObj.style;
11201120
this.styleName_ = styleObj.name;
11211121

@@ -1137,7 +1137,7 @@ export class BlockSvg
11371137

11381138
if (blockStyle) {
11391139
this.hat = blockStyle.hat;
1140-
this.pathObject.setStyle(blockStyle);
1140+
this.pathObject.setStyle?.(blockStyle);
11411141
// Set colour to match Block.
11421142
this.colour_ = blockStyle.colourPrimary;
11431143
this.style = blockStyle;

core/renderers/common/i_path_object.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,6 @@ export interface IPathObject {
4949
*/
5050
setPath(pathString: string): void;
5151

52-
/**
53-
* Apply the stored colours to the block's path, taking into account whether
54-
* the paths belong to a shadow block.
55-
*
56-
* @param block The source block.
57-
*/
58-
applyColour(block: BlockSvg): void;
59-
60-
/**
61-
* Update the style.
62-
*
63-
* @param blockStyle The block style to use.
64-
*/
65-
setStyle(blockStyle: BlockStyle): void;
66-
6752
/**
6853
* Flip the SVG paths in RTL.
6954
*/
@@ -130,8 +115,23 @@ export interface IPathObject {
130115
rtl: boolean,
131116
): void;
132117

118+
/**
119+
* Apply the stored colours to the block's path, taking into account whether
120+
* the paths belong to a shadow block.
121+
*
122+
* @param block The source block.
123+
*/
124+
applyColour?(block: BlockSvg): void;
125+
133126
/**
134127
* Removes any highlight associated with the given connection, if it exists.
135128
*/
136129
removeConnectionHighlight?(connection: RenderedConnection): void;
130+
131+
/**
132+
* Update the style.
133+
*
134+
* @param blockStyle The block style to use.
135+
*/
136+
setStyle?(blockStyle: BlockStyle): void;
137137
}

0 commit comments

Comments
 (0)