aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-11-22 01:09:04 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-11-22 01:09:04 +0100
commitb3d72678192902252613e654c3fada1e57250ba7 (patch)
tree69cb22231f401227b169ce6a7b1c9637140cf1a4 /static
parentRework popup components. (diff)
downloadcalp-b3d72678192902252613e654c3fada1e57250ba7.tar.gz
calp-b3d72678192902252613e654c3fada1e57250ba7.tar.xz
Change innerHTML to textContent.
Also changed some innerText to textContent
Diffstat (limited to 'static')
-rw-r--r--static/clock.ts2
-rw-r--r--static/components/vevent-dl.ts4
-rw-r--r--static/components/vevent.ts4
-rw-r--r--static/script.ts5
-rw-r--r--static/vevent.ts24
5 files changed, 21 insertions, 18 deletions
diff --git a/static/clock.ts b/static/clock.ts
index 9171b8a8..a2d22e00 100644
--- a/static/clock.ts
+++ b/static/clock.ts
@@ -110,7 +110,7 @@ customElements.define('today-button', TodayButton)
class CurrentTime extends ClockElement {
update(now: Date) {
- this.innerHTML = now.format('~H:~M:~S')
+ this.textContent = now.format('~H:~M:~S')
}
}
customElements.define('current-time', CurrentTime)
diff --git a/static/components/vevent-dl.ts b/static/components/vevent-dl.ts
index dfab8183..a792c07f 100644
--- a/static/components/vevent-dl.ts
+++ b/static/components/vevent-dl.ts
@@ -19,7 +19,7 @@ class VEventDL extends ComponentVEvent {
function buildDescriptionList(data: [string, any][]): HTMLElement {
let dl = document.createElement('dl');
for (let [key, val] of data) {
- dl.appendChild(makeElement('dt', { innerText: key }))
+ dl.appendChild(makeElement('dt', { textContent: key }))
let fmtVal: string = val;
if (val instanceof Date) {
fmtVal = val.format(
@@ -29,7 +29,7 @@ function buildDescriptionList(data: [string, any][]): HTMLElement {
} else if (val instanceof RecurrenceRule) {
fmtVal = JSON.stringify(val.to_jcal())
}
- dl.appendChild(makeElement('dd', { innerText: fmtVal }))
+ dl.appendChild(makeElement('dd', { textContent: fmtVal }))
}
return dl;
}
diff --git a/static/components/vevent.ts b/static/components/vevent.ts
index 23eba0a9..cf28045a 100644
--- a/static/components/vevent.ts
+++ b/static/components/vevent.ts
@@ -60,9 +60,9 @@ class ComponentVEvent extends HTMLElement {
let d, fmt;
if ((d = data.getProperty(p))) {
if ((fmt = el.dataset.fmt)) {
- el.innerHTML = d.format(fmt);
+ el.textContent = d.format(fmt);
} else {
- el.innerHTML = d;
+ el.textContent = d;
}
}
}
diff --git a/static/script.ts b/static/script.ts
index 2f418918..df5e2c97 100644
--- a/static/script.ts
+++ b/static/script.ts
@@ -33,7 +33,10 @@ window.addEventListener('load', function() {
for (let calendar of div2.children) {
let calendar_name = calendar.getAttribute('key')!;
for (let child of calendar.children) {
- let uid = child.innerHTML;
+ let uid = child.textContent;
+ if (!uid) {
+ throw "UID required"
+ }
event_calendar_mapping.set(uid, calendar_name);
let obj = vcal_objects.get(uid);
if (obj) obj.calendar = calendar_name
diff --git a/static/vevent.ts b/static/vevent.ts
index dd75d362..9bfd8dcf 100644
--- a/static/vevent.ts
+++ b/static/vevent.ts
@@ -266,7 +266,7 @@ function xml_to_recurrence_rule(xml: Element): RecurrenceRule {
for (let child of xml.children) {
/* see appendix a 3.3.10 RECUR of RFC 6321 */
- let t = child.innerHTML;
+ let t = child.textContent || '';
let tn = child.tagName.toLowerCase()
switch (tn) {
@@ -326,40 +326,40 @@ function make_vevent_value_(value_tag: Element) {
/* Base64 to binary
Seems to handle inline whitespace, which xCal standard reqires
*/
- return atob(value_tag.innerHTML)
+ return atob(value_tag.textContent || '')
case 'boolean':
- switch (value_tag.innerHTML) {
+ switch (value_tag.textContent) {
case 'true': return true;
case 'false': return false;
default:
- console.warn(`Bad boolean ${value_tag.innerHTML}, defaulting with !!`)
- return !!value_tag.innerHTML;
+ console.warn(`Bad boolean ${value_tag.textContent}, defaulting with !!`)
+ return !!value_tag.textContent;
}
case 'time':
case 'date':
case 'date-time':
- return parseDate(value_tag.innerHTML);
+ return parseDate(value_tag.textContent || '');
case 'duration':
/* TODO duration parser here 'P1D' */
- return value_tag.innerHTML;
+ return value_tag.textContent;
case 'float':
case 'integer':
- return +value_tag.innerHTML;
+ return Number(value_tag.textContent);
case 'period':
/* TODO has sub components, meaning that a string wont do */
let start = value_tag.getElementsByTagName('start')[0]
- parseDate(start.innerHTML);
+ parseDate(start.textContent || '');
let other;
if ((other = value_tag.getElementsByTagName('end')[0])) {
- return parseDate(other.innerHTML)
+ return parseDate(other.textContent || '')
} else if ((other = value_tag.getElementsByTagName('duration')[0])) {
/* TODO parse duration */
- return other.innerHTML
+ return other.textContent
} else {
console.warn('Invalid end to period, defaulting to 1H');
return new Date(3600);
@@ -377,7 +377,7 @@ function make_vevent_value_(value_tag: Element) {
case 'cal-address':
case 'uri':
case 'text':
- return value_tag.innerHTML;
+ return value_tag.textContent;
}
}