Avoid removing listeners that don't exist

This commit is contained in:
Lucas Varela 2023-03-23 20:00:31 -03:00
parent 3d79768549
commit 4c42ccdb3a

View file

@ -748,8 +748,15 @@ export default class Block extends EventsDispatcher<BlockEvents> {
* Is fired when Block will be unselected
*/
public willUnselect(): void {
this.mutationObserver?.disconnect();
this.removeInputEvents();
/**
* There's no need to disconnect the observer or
* remove listeners if shouldUpdateOnMutation is false,
* since they weren't set up in the first place.
*/
if (this.tool.shouldUpdateOnMutation) {
this.mutationObserver.disconnect();
this.removeInputEvents();
}
}
/**