From 7cb8eac8e47f631eec6653e5439bcfb08d923224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 17 May 2021 02:04:40 +0200 Subject: JS Fix adding of missing vcal properties. --- static/vcal.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/static/vcal.js b/static/vcal.js index f86d53de..93cfc028 100644 --- a/static/vcal.js +++ b/static/vcal.js @@ -278,7 +278,23 @@ class VComponent { }, set: function (value) { console.log("set", property_name, value); - this._values[property_name].value = value; + /* Semi dirty hack to add properties which are missing. + Since we initialize without a type just guess depending + on the field name */ + if (! this._values[property_name]) { + let type_arr + = valid_input_types[property_name.toUpperCase()] + || ['unknown']; + let type = type_arr[0]; + /* Types which can take arrays are interesting */ + if (type instanceof Array) { + type = type[0]; + } + this._values[property_name] + = new VCalParameter(type, value) + } else { + this._values[property_name].value = value; + } console.log(this._slots[property_name].length, this._slots[property_name]); /* TODO validate type */ -- cgit v1.2.3