@forcecalendar/core 2.1.7 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -731,23 +731,29 @@ export class Calendar {
|
|
|
731
731
|
* Destroy the calendar and clean up
|
|
732
732
|
*/
|
|
733
733
|
destroy() {
|
|
734
|
+
// Emit destroy event before clearing listeners
|
|
735
|
+
this._emit('destroy');
|
|
736
|
+
|
|
734
737
|
// Clear all listeners
|
|
735
738
|
this.listeners.clear();
|
|
736
739
|
|
|
737
740
|
// Properly destroy EventStore (clears events, caches, and cleanup timers)
|
|
738
741
|
this.eventStore.destroy();
|
|
739
742
|
|
|
740
|
-
// Clear plugins
|
|
743
|
+
// Clear plugins — wrap each uninstall in try-catch so one failure
|
|
744
|
+
// doesn't prevent cleanup of remaining plugins
|
|
741
745
|
this.plugins.forEach(plugin => {
|
|
742
746
|
if (typeof plugin.uninstall === 'function') {
|
|
743
|
-
|
|
747
|
+
try {
|
|
748
|
+
plugin.uninstall(this);
|
|
749
|
+
} catch (error) {
|
|
750
|
+
console.error('Error uninstalling plugin:', error);
|
|
751
|
+
}
|
|
744
752
|
}
|
|
745
753
|
});
|
|
746
754
|
this.plugins.clear();
|
|
747
755
|
|
|
748
756
|
// Clear view instances
|
|
749
757
|
this.views.clear();
|
|
750
|
-
|
|
751
|
-
this._emit('destroy');
|
|
752
758
|
}
|
|
753
759
|
} // Test workflow
|
|
@@ -288,9 +288,13 @@ export class DateUtils {
|
|
|
288
288
|
* @returns {number}
|
|
289
289
|
*/
|
|
290
290
|
static getWeekNumber(date) {
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
291
|
+
// ISO 8601: week 1 is the week containing the first Thursday of the year
|
|
292
|
+
const target = new Date(date);
|
|
293
|
+
target.setHours(0, 0, 0, 0);
|
|
294
|
+
// Set to nearest Thursday (current date + 4 - current day number, with Sunday as 7)
|
|
295
|
+
target.setDate(target.getDate() + 4 - (target.getDay() || 7));
|
|
296
|
+
const yearStart = new Date(target.getFullYear(), 0, 1);
|
|
297
|
+
return Math.ceil(((target - yearStart) / 86400000 + 1) / 7);
|
|
294
298
|
}
|
|
295
299
|
|
|
296
300
|
/**
|
|
@@ -102,6 +102,13 @@ export class StateManager {
|
|
|
102
102
|
updates = updates(oldState);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
// Sanitize keys to prevent prototype pollution
|
|
106
|
+
if (updates && typeof updates === 'object') {
|
|
107
|
+
delete updates.__proto__;
|
|
108
|
+
delete updates.constructor;
|
|
109
|
+
delete updates.prototype;
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
// Create new state with updates
|
|
106
113
|
const newState = {
|
|
107
114
|
...oldState,
|