diff --git a/src/lib/ical-io.js b/src/lib/ical-io.js index 6899ea6..ac296e0 100644 --- a/src/lib/ical-io.js +++ b/src/lib/ical-io.js @@ -111,7 +111,9 @@ export function parseICS(text) { method: vcalendar.getFirstPropertyValue('method') || null, xWrCalname: vcalendar.getFirstPropertyValue('x-wr-calname') || null, xWrTimezone: vcalendar.getFirstPropertyValue('x-wr-timezone') || null, - vtimezones: vcalendar.getAllSubcomponents('vtimezone'), + // Store raw jCal arrays (not ICAL.Component instances) so the meta stays + // plain-serializable for Vue reactivity and JSON snapshot cloning. + vtimezones: vcalendar.getAllSubcomponents('vtimezone').map((vtz) => vtz.jCal), } // Events @@ -185,9 +187,10 @@ export function serializeICS({ meta, events }) { if (meta.xWrCalname) vcalendar.updatePropertyWithValue('x-wr-calname', meta.xWrCalname) if (meta.xWrTimezone) vcalendar.updatePropertyWithValue('x-wr-timezone', meta.xWrTimezone) - // Re-add VTIMEZONEs (clone jCal to avoid moving from original parent) - for (const vtz of meta.vtimezones || []) { - vcalendar.addSubcomponent(new ICAL.Component(vtz.jCal)) + // Re-add VTIMEZONEs. meta.vtimezones stores raw jCal arrays (see parseICS), + // so wrap each directly in a new Component (avoids moving the original). + for (const vtzJCal of meta.vtimezones || []) { + vcalendar.addSubcomponent(new ICAL.Component(vtzJCal)) } for (const ev of events) {