Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Decoration.isDisposed can be true #4465

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/common/services/DecorationService.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
2 changes: 1 addition & 1 deletion src/common/services/DecorationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down