From 724828b505eb1744e3616990528547e883481f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 8 Nov 2021 18:29:35 +0100 Subject: JS normalize all vevent property keys to upper case. --- static/vevent.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'static') diff --git a/static/vevent.ts b/static/vevent.ts index 377cb6ae..50c3e1a9 100644 --- a/static/vevent.ts +++ b/static/vevent.ts @@ -82,13 +82,21 @@ class VEvent { */ registered: Redrawable[] - constructor(properties: Map = new Map(), components: VEvent[] = []) { - this.properties = properties; + constructor(properties: Map = new Map(), components: VEvent[] = []) { this.components = components; this.registered = []; + /* Re-normalize all given keys to upper case. We could require + * that beforehand, this is much more reliable, for only a + * marginal performance hit. + */ + this.properties = new Map; + for (const [key, value] of properties) { + this.properties.set(key.toUpperCase(), value); + } } getProperty(key: string): any | undefined { + key = key.toUpperCase() let e = this.properties.get(key); if (!e) return e; return e.value; @@ -99,10 +107,9 @@ class VEvent { } setProperty(key: string, value: any) { - console.log(key, value); + key = key.toUpperCase(); let e = this.properties.get(key); if (!e) { - key = key.toUpperCase() let type: ical_type let type_ = valid_input_types.get(key) if (type_ === undefined) { @@ -118,8 +125,6 @@ class VEvent { e.value = value; } for (let el of this.registered) { - /* TODO update correct fields, allow component to redraw themselves */ - console.log(el); el.redraw(this); } } -- cgit v1.2.3