From ab3342171fba016b0c5f19b860336ed49a08f3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 10 Jul 2022 14:56:19 +0200 Subject: Change JS formatters interface. Now the application of formatters are centralized. It also allowed me to easily suround stuff in try-catch, since I otherwise had problems with formatters failing, and nothing showing up. --- static/components/vevent-description.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'static/components') diff --git a/static/components/vevent-description.ts b/static/components/vevent-description.ts index 463725f1..b44185e7 100644 --- a/static/components/vevent-description.ts +++ b/static/components/vevent-description.ts @@ -2,7 +2,7 @@ export { ComponentDescription } import { VEvent } from '../vevent' import { ComponentVEvent } from './vevent' -import { formatters } from '../formatters' +import { format } from '../formatters' /* @@ -23,14 +23,7 @@ class ComponentDescription extends ComponentVEvent { for (let el of body.querySelectorAll('[data-property]')) { if (!(el instanceof HTMLElement)) continue; - let p = el.dataset.property!; - let d; - if ((d = data.getProperty(p))) { - let key = p.toLowerCase(); - let f = formatters.get(key); - if (f) f(el, data, d); - else window.formatters.get('default')!(el, data, d); - } + format(el, data, el.dataset.property!); } let repeating = body.getElementsByClassName('repeating')[0] as HTMLElement -- cgit v1.2.3