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

SVGRender: explicitly use array index as ID #341

Merged
merged 1 commit into from
Aug 4, 2023
Merged
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
8 changes: 3 additions & 5 deletions src/graph/svg-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export class SVGRender {
private _worker: Worker;

private _listeners: Array<RenderRequestListener> = [];
private _nextId = 0;

constructor() {
this._worker = VizWorker;

Expand All @@ -58,9 +56,9 @@ export class SVGRender {

_renderString(src: string): Promise<string> {
return new Promise((resolve, reject) => {
const id = this._nextId++;
const id = this._listeners.length;

this._listeners[id] = function (error, result): void {
this._listeners.push(function (error, result): void {
if (error) {
const e = new Error(error.message);
if (error.fileName) (e as any).fileName = error.fileName;
Expand All @@ -69,7 +67,7 @@ export class SVGRender {
return reject(e);
}
resolve(result);
};
});

const renderRequest: RenderRequest = { id, src };
this._worker.postMessage(renderRequest);
Expand Down