feat!: allow blocks to receive their own delete events (#6337)

* feat!: allow blocks to receive their own delete events

* fix: move block tests back into main directory

* chore: add a test for disposing of callers

* chore: add test for delete being received

* chore: add comment about why we have to run the clock twice

* chore: fix whitespace

* chore: fix whitespace

* chore: fix imports in tests

* chore: bump mocha timeout

* chore: bump timeout again?

* chore: eliminate the possibility that tests are actually timing out

* chore: change timeout back

* chore: remove tests that might be the problematic ones

* chore: attempt enabling delete event test

* chore: enable lists tests

* chore: try ternary test as well

* chore: actually add block test files

* chore: enable remaining tests
This commit is contained in:
Beka Westberg
2022-08-16 22:49:40 +00:00
committed by GitHub
parent 8689ab2ad5
commit e9920a54e0
7 changed files with 174 additions and 95 deletions

View File

@@ -316,18 +316,18 @@ export class Block implements IASTNodeLocation, IDeletable {
*/
dispose(healStack: boolean) {
if (this.disposed) {
// Already deleted.
return;
}
// Terminate onchange event calls.
if (this.onchangeWrapper_) {
this.workspace.removeChangeListener(this.onchangeWrapper_);
}
this.unplug(healStack);
if (eventUtils.isEnabled()) {
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_DELETE))!(this));
}
if (this.onchangeWrapper_) {
this.workspace.removeChangeListener(this.onchangeWrapper_);
}
eventUtils.disable();
try {