Skip to content
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
14 changes: 11 additions & 3 deletions src/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@
private readonly _mutationObserverCallbacks: Obj<EventCallback[]> = {};
readonly type: string = 'default';
model?: Observable;
isDeleted?: boolean;

constructor(readonly _el: T) {
constructor(readonly __el: T) {
// Store a reference to this element within the native browser DOM.
_el._view = this;
__el._view = this;
}

get _el() {
if (this.isDeleted) console.error('Trying to access a deleted element:', this);
return this.__el;
}

get id() {
Expand Down Expand Up @@ -602,6 +608,7 @@

/** Removes listeners and model data from el */
private unsubscribe() {
this.isDeleted = true;
this.model?.clear();
this._mutationObserver?.disconnect();
this.offAll();
Expand All @@ -610,6 +617,7 @@
child.unsubscribe();
}

/* Disabled temporarily
// hack to avoid TS notification
// about setting undefined value to readonly properties
delete (this as any)._el;
Expand All @@ -618,7 +626,7 @@

// remove mutation observer instances
delete (this as any)._mutationObserver;
delete (this as any)._mutationObserverCallbacks;
delete (this as any)._mutationObserverCallbacks; */
}

/** Removes this element. */
Expand Down Expand Up @@ -1045,7 +1053,7 @@
if (!obj) return this.setAttr('d', '');
const attributes: SVGDrawingOptions = {};
for (const p of ['mark', 'arrows', 'round'] as const) {
if (this.hasAttr(p)) attributes[p] = this.attr(p) as any;

Check warning on line 1056 in src/elements.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20

Unexpected any. Specify a different type

Check warning on line 1056 in src/elements.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18

Unexpected any. Specify a different type
}
if (this.hasClass('fill')) attributes.fill = 'fill';
if (this.hasAttr('size')) attributes.size = (+this.attr('size')) || undefined;
Expand Down
Loading