Skip to content

Commit 2fdb469

Browse files
authored
Merge pull request #4465 from Tyriar/4410
Ensure Decoration.isDisposed can be true
2 parents c8e633e + c546f7c commit 2fdb469

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
3+
* @license MIT
4+
*/
5+
6+
import { assert } from 'chai';
7+
import { DecorationService } from './DecorationService';
8+
import { EventEmitter } from 'common/EventEmitter';
9+
import { IMarker } from 'common/Types';
10+
import { Disposable } from 'common/Lifecycle';
11+
12+
const fakeMarker: IMarker = Object.freeze(new class extends Disposable {
13+
public readonly id = 1;
14+
public readonly line = 1;
15+
public readonly isDisposed = false;
16+
public readonly onDispose = new EventEmitter<void>().event;
17+
}());
18+
19+
describe('DecorationService', () => {
20+
it('should set isDisposed to true after dispose', () => {
21+
const service = new DecorationService();
22+
const decoration = service.registerDecoration({
23+
marker: fakeMarker
24+
});
25+
assert.ok(decoration);
26+
assert.isFalse(decoration!.isDisposed);
27+
decoration!.dispose();
28+
assert.isTrue(decoration!.isDisposed);
29+
});
30+
});

src/common/services/DecorationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class DecorationService extends Disposable implements IDecorationService
104104
class Decoration extends Disposable implements IInternalDecoration {
105105
public readonly marker: IMarker;
106106
public element: HTMLElement | undefined;
107-
public isDisposed: boolean = false;
107+
public get isDisposed(): boolean { return this._isDisposed; }
108108

109109
public readonly onRenderEmitter = this.register(new EventEmitter<HTMLElement>());
110110
public readonly onRender = this.onRenderEmitter.event;

0 commit comments

Comments
 (0)