@@ -58,7 +58,7 @@ export interface Parameter {
5858 type ?: string ;
5959}
6060
61- export type ClassMethodDefBlock = Blockly . Block & ClassMethodDefMixin & Blockly . BlockSvg ;
61+ export type ClassMethodDefBlock = Blockly . Block & ClassMethodDefMixin ;
6262interface ClassMethodDefMixin extends ClassMethodDefMixinType {
6363 mrcMethodId : string ,
6464 mrcCanChangeSignature : boolean ,
@@ -182,12 +182,16 @@ const CLASS_METHOD_DEF = {
182182 if ( this . mrcCanChangeSignature ) {
183183 const nameField = new Blockly . FieldTextInput ( name ) ;
184184 input . insertFieldAt ( 0 , nameField , FIELD_METHOD_NAME ) ;
185- this . setMutator ( paramContainer . getMutatorIcon ( this ) ) ;
185+ if ( this . rendered ) {
186+ this . setMutator ( paramContainer . getMutatorIcon ( this as unknown as Blockly . BlockSvg ) ) ;
187+ }
186188 nameField . setValidator ( this . mrcNameFieldValidator . bind ( this , nameField ) ) ;
187189 } else {
188190 input . insertFieldAt ( 0 , createFieldNonEditableText ( name ) , FIELD_METHOD_NAME ) ;
189- // Case because a current bug in blockly where it won't allow passing null to Blockly.Block.setMutator makes it necessary.
190- ( this as Blockly . BlockSvg ) . setMutator ( null ) ;
191+ // To call setMutator(null), this must be casted to BlockSvg.
192+ if ( this . rendered ) {
193+ ( this as unknown as Blockly . BlockSvg ) . setMutator ( null ) ;
194+ }
191195 }
192196 this . mrcUpdateParams ( ) ;
193197 this . mrcUpdateReturnInput ( ) ;
@@ -231,7 +235,9 @@ const CLASS_METHOD_DEF = {
231235 * mrcOnMutatorOpen is called when the mutator on a ClassMethodDefBlock is opened.
232236 */
233237 mrcOnMutatorOpen : function ( this : ClassMethodDefBlock ) : void {
234- paramContainer . onMutatorOpen ( this ) ;
238+ if ( this . rendered ) {
239+ paramContainer . onMutatorOpen ( this as unknown as Blockly . BlockSvg ) ;
240+ }
235241 } ,
236242 mrcRenameParameter : function ( this : ClassMethodDefBlock , oldName : string , newName : string ) {
237243 const nextBlock = this . getInputTargetBlock ( INPUT_STACK ) ;
0 commit comments