From 6f23cf88f362122cee735f8df314dc4caae87947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 16 Jun 2022 19:08:59 +0200 Subject: Change to proper javascript privates. --- static/vevent.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'static/vevent.ts') diff --git a/static/vevent.ts b/static/vevent.ts index 5419eb60..6a2c6f0f 100644 --- a/static/vevent.ts +++ b/static/vevent.ts @@ -101,31 +101,37 @@ class VEvent { */ registered: Redrawable[] - _calendar: string | null = null; + #calendar: string | null = null; - _changelog: ChangeLogEntry[] = [] + #changelog: ChangeLogEntry[] = [] + + /* Iterator instead of direct return to ensure the receiver doesn't + modify the array */ + get changelog(): IterableIterator<[number, ChangeLogEntry]> { + return this.#changelog.entries(); + } addlog(entry: ChangeLogEntry) { - let len = this._changelog.length - let last = this._changelog[len - 1] + let len = this.#changelog.length + let last = this.#changelog[len - 1] // console.log('entry = ', entry, ', last = ', last); if (!last) { // console.log('Adding new entry', entry, this.getProperty('uid')); - this._changelog.push(entry); + this.#changelog.push(entry); return; } if (entry.type === last.type && entry.name === last.name && entry.from === last.to) { - this._changelog.pop(); + this.#changelog.pop(); entry.from = last.from // console.log('Changing old entry', entry, this.getProperty('uid')); - this._changelog.push(entry) + this.#changelog.push(entry) } else { - this._changelog.push(entry) + this.#changelog.push(entry) } } @@ -244,17 +250,17 @@ class VEvent { this.addlog({ type: 'calendar', name: '', - from: this._calendar, + from: this.#calendar, to: calendar, }); - this._calendar = calendar; + this.#calendar = calendar; for (let el of this.registered) { el.redraw(this); } } get calendar(): string | null { - return this._calendar; + return this.#calendar; } register(htmlNode: Redrawable) { -- cgit v1.2.3