From 8da01b382ce43802ef164b86cc7e8c714d85a0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 11 Jun 2022 23:18:11 +0200 Subject: Follow all instances of tagName with toLowerCase. A HTML document returns tag names as upper case, while xml documents return them as lower case (or possibly their original case). --- static/components/vevent.ts | 2 +- static/globals.ts | 2 +- static/vevent.ts | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'static') diff --git a/static/components/vevent.ts b/static/components/vevent.ts index b72cda90..2193eabc 100644 --- a/static/components/vevent.ts +++ b/static/components/vevent.ts @@ -15,7 +15,7 @@ abstract class ComponentVEvent extends HTMLElement { constructor(uid?: string) { super(); - this.template = document.getElementById(this.tagName) as HTMLTemplateElement | null + this.template = document.getElementById(this.tagName.toLowerCase()) as HTMLTemplateElement | null let real_uid; diff --git a/static/globals.ts b/static/globals.ts index 2fc12933..ddc9113e 100644 --- a/static/globals.ts +++ b/static/globals.ts @@ -51,7 +51,7 @@ function find_block(uid: uid): ComponentBlock | null { return null; } for (let el of obj.registered) { - if (el.tagName === 'vevent-block') { + if (el.tagName.toLowerCase() === 'vevent-block') { return el as ComponentBlock; } } diff --git a/static/vevent.ts b/static/vevent.ts index 56c9019a..5419eb60 100644 --- a/static/vevent.ts +++ b/static/vevent.ts @@ -298,7 +298,7 @@ function make_vevent_value(value_tag: Element): VEventValue { /* TODO parameters */ return new VEventValue( /* TODO error on invalid type? */ - value_tag.tagName as ical_type, + value_tag.tagName.toLowerCase() as ical_type, make_vevent_value_(value_tag)); } @@ -441,7 +441,7 @@ function xml_to_recurrence_rule(xml: Element): RecurrenceRule { function make_vevent_value_(value_tag: Element): string | boolean | Date | number | RecurrenceRule { /* RFC6321 3.6. */ - switch (value_tag.tagName) { + switch (value_tag.tagName.toLowerCase()) { case 'binary': /* Base64 to binary Seems to handle inline whitespace, which xCal standard reqires @@ -518,10 +518,10 @@ function xml_to_vcal(xml: Element): VEvent { for (var j = 0; j < tag.childElementCount; j++) { let child = tag.childNodes[j]; if (!(child instanceof Element)) continue; - if (child.tagName == 'parameters') { + if (child.tagName.toLowerCase() == 'parameters') { parameters = /* TODO handle parameters */ {}; continue value_loop; - } else switch (tag.tagName) { + } else switch (tag.tagName.toLowerCase()) { /* These can contain multiple value tags, per RFC6321 3.4.1.1. */ case 'categories': @@ -535,7 +535,7 @@ function xml_to_vcal(xml: Element): VEvent { value = make_vevent_value(child); } } - property_map.set(tag.tagName, value); + property_map.set(tag.tagName.toLowerCase(), value); } } -- cgit v1.2.3 From b788aa05b12642ebacef394238a54d11c3d64e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 11 Jun 2022 23:44:53 +0200 Subject: Handle error for user-additions salar. The script crashes just as before, but now we get slightly better error messages. --- static/user/user-additions.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'static') diff --git a/static/user/user-additions.js b/static/user/user-additions.js index 0de825e8..c0579df5 100644 --- a/static/user/user-additions.js +++ b/static/user/user-additions.js @@ -34,8 +34,10 @@ window.formatters.set('description', (el, d) => { window.salar = new Promise((resolve, reject) => fetch('/static/user/salar.json') - .then(d => d.json()) - .then(d => resolve(d))) + .then(resp => { if (! resp.ok) reject("404"); else resp.json() }) + .then(d => resolve(d)) + .catch(err => reject(err)) +) window.formatters.set('location', async function(el, d) { @@ -46,7 +48,12 @@ window.formatters.set('location', async function(el, d) { return; } - let salar = await window.salar; + try { + let salar = await window.salar; + } catch (e) { + console.warn("Location formatter failed", e); + return; + } let name = m[1] let frag = salar[name]; -- cgit v1.2.3