update connection logic

This commit is contained in:
“chrisshank” 2024-12-15 10:28:30 -08:00
parent d9c8a88796
commit bbd0c6684d
1 changed files with 14 additions and 10 deletions

View File

@ -49,12 +49,14 @@ export class FolkBaseConnection extends FolkElement {
this.sourceRect = DOMRectReadOnly.fromRect(vertex); this.sourceRect = DOMRectReadOnly.fromRect(vertex);
} else { } else {
this.sourceElement = document.querySelector(this.source); this.sourceElement = document.querySelector(this.source);
}
}
if (this.sourceElement === null) { if (changedProperties.has('sourceElement')) {
this.sourceRect = null; if (this.sourceElement === null) {
} else { this.sourceRect = null;
folkObserver.observe(this.sourceElement, this.#sourceCallback); } else {
} folkObserver.observe(this.sourceElement, this.#sourceCallback);
} }
} }
@ -69,12 +71,14 @@ export class FolkBaseConnection extends FolkElement {
this.targetRect = DOMRectReadOnly.fromRect(vertex); this.targetRect = DOMRectReadOnly.fromRect(vertex);
} else { } else {
this.targetElement = document.querySelector(this.target); this.targetElement = document.querySelector(this.target);
}
}
if (this.targetElement === null) { if (changedProperties.has('targetElement')) {
this.targetRect = null; if (this.targetElement === null) {
} else { this.targetRect = null;
folkObserver.observe(this.targetElement, this.#targetCallback); } else {
} folkObserver.observe(this.targetElement, this.#targetCallback);
} }
} }
} }