mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge pull request #4465 from Tyriar/4410
Ensure Decoration.isDisposed can be true
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user