Merge pull request #4465 from Tyriar/4410

Ensure Decoration.isDisposed can be true
This commit is contained in:
Daniel Imms
2023-03-31 12:21:52 -07:00
committed by GitHub
2 changed files with 31 additions and 1 deletions
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { assert } from 'chai';
import { DecorationService } from './DecorationService';
import { EventEmitter } from 'common/EventEmitter';
import { IMarker } from 'common/Types';
import { Disposable } from 'common/Lifecycle';
const fakeMarker: IMarker = Object.freeze(new class extends Disposable {
public readonly id = 1;
public readonly line = 1;
public readonly isDisposed = false;
public readonly onDispose = new EventEmitter<void>().event;
}());
describe('DecorationService', () => {
it('should set isDisposed to true after dispose', () => {
const service = new DecorationService();
const decoration = service.registerDecoration({
marker: fakeMarker
});
assert.ok(decoration);
assert.isFalse(decoration!.isDisposed);
decoration!.dispose();
assert.isTrue(decoration!.isDisposed);
});
});
+1 -1
View File
@@ -104,7 +104,7 @@ export class DecorationService extends Disposable implements IDecorationService
class Decoration extends Disposable implements IInternalDecoration {
public readonly marker: IMarker;
public element: HTMLElement | undefined;
public isDisposed: boolean = false;
public get isDisposed(): boolean { return this._isDisposed; }
public readonly onRenderEmitter = this.register(new EventEmitter<HTMLElement>());
public readonly onRender = this.onRenderEmitter.event;