@syncfusion/ej2-base 22.2.5 → 22.2.10

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.
@@ -7230,6 +7230,7 @@ let Component = class Component extends Base {
7230
7230
  }
7231
7231
  if (this.enablePersistence) {
7232
7232
  this.setPersistData();
7233
+ this.detachUnloadEvent();
7233
7234
  }
7234
7235
  this.localObserver.destroy();
7235
7236
  if (this.refreshing) {
@@ -7291,6 +7292,25 @@ let Component = class Component extends Base {
7291
7292
  return window.localStorage.getItem(eleId);
7292
7293
  }
7293
7294
  }
7295
+ /**
7296
+ * Adding unload event to persist data when enable persistence true
7297
+ */
7298
+ attachUnloadEvent() {
7299
+ this.handleUnload = this.handleUnload.bind(this);
7300
+ window.addEventListener('unload', this.handleUnload);
7301
+ }
7302
+ /**
7303
+ * Handling unload event to persist data when enable persistence true
7304
+ */
7305
+ handleUnload() {
7306
+ this.setPersistData();
7307
+ }
7308
+ /**
7309
+ * Removing unload event to persist data when enable persistence true
7310
+ */
7311
+ detachUnloadEvent() {
7312
+ window.removeEventListener('unload', this.handleUnload);
7313
+ }
7294
7314
  /**
7295
7315
  * Appends the control within the given HTML element
7296
7316
  *
@@ -7313,7 +7333,7 @@ let Component = class Component extends Base {
7313
7333
  }
7314
7334
  if (this.enablePersistence) {
7315
7335
  this.mergePersistData();
7316
- window.addEventListener('unload', this.setPersistData.bind(this));
7336
+ this.attachUnloadEvent();
7317
7337
  }
7318
7338
  const inst = getValue('ej2_instances', this.element);
7319
7339
  if (!inst || inst.indexOf(this) === -1) {