mirror of
https://github.com/sissbruecker/linkding.git
synced 2026-02-28 06:53:12 +08:00
Fix web component initialization timing
This commit is contained in:
@@ -1,28 +1,19 @@
|
||||
class ClearButton extends HTMLElement {
|
||||
connectedCallback() {
|
||||
requestAnimationFrame(() => {
|
||||
this.field = document.getElementById(this.dataset.for);
|
||||
if (!this.field) {
|
||||
console.error(`Field with ID ${this.dataset.for} not found`);
|
||||
return;
|
||||
}
|
||||
this.update = this.update.bind(this);
|
||||
this.clear = this.clear.bind(this);
|
||||
import { HeadlessElement } from "../utils/element";
|
||||
|
||||
this.addEventListener("click", this.clear);
|
||||
this.field.addEventListener("input", this.update);
|
||||
this.field.addEventListener("value-changed", this.update);
|
||||
this.update();
|
||||
});
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
class ClearButton extends HeadlessElement {
|
||||
init() {
|
||||
this.field = document.getElementById(this.dataset.for);
|
||||
if (!this.field) {
|
||||
console.error(`Field with ID ${this.dataset.for} not found`);
|
||||
return;
|
||||
}
|
||||
this.removeEventListener("click", this.clear);
|
||||
this.field.removeEventListener("input", this.update);
|
||||
this.field.removeEventListener("value-changed", this.update);
|
||||
this.update = this.update.bind(this);
|
||||
this.clear = this.clear.bind(this);
|
||||
|
||||
this.addEventListener("click", this.clear);
|
||||
this.field.addEventListener("input", this.update);
|
||||
this.field.addEventListener("value-changed", this.update);
|
||||
this.update();
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
Reference in New Issue
Block a user