Skip to content

Commit 7c22c46

Browse files
authored
refactor: Add addClass and removeClass methods to blockSvg (#8337)
* refactor: Add `addClass` and `removeClass` methods to blockSvg * fix: lint * fix: jsdoc
1 parent 9684942 commit 7c22c46

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

core/block_svg.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,24 @@ export class BlockSvg
671671
}
672672
}
673673

674+
/**
675+
* Add a CSS class to the SVG group of this block.
676+
*
677+
* @param className
678+
*/
679+
addClass(className: string) {
680+
dom.addClass(this.svgGroup_, className);
681+
}
682+
683+
/**
684+
* Remove a CSS class from the SVG group of this block.
685+
*
686+
* @param className
687+
*/
688+
removeClass(className: string) {
689+
dom.removeClass(this.svgGroup_, className);
690+
}
691+
674692
/**
675693
* Recursively adds or removes the dragging class to this node and its
676694
* children.
@@ -683,10 +701,10 @@ export class BlockSvg
683701
if (adding) {
684702
this.translation = '';
685703
common.draggingConnections.push(...this.getConnections_(true));
686-
dom.addClass(this.svgGroup_, 'blocklyDragging');
704+
this.addClass('blocklyDragging');
687705
} else {
688706
common.draggingConnections.length = 0;
689-
dom.removeClass(this.svgGroup_, 'blocklyDragging');
707+
this.removeClass('blocklyDragging');
690708
}
691709
// Recurse through all blocks attached under this one.
692710
for (let i = 0; i < this.childBlocks_.length; i++) {

0 commit comments

Comments
 (0)