add-to-calendar-button 2.6.2 → 2.6.3

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.
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: 3D
7
7
  *
8
- * Version: 2.6.2
8
+ * Version: 2.6.3
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Date
7
7
  *
8
- * Version: 2.6.2
8
+ * Version: 2.6.3
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Flat
7
7
  *
8
- * Version: 2.6.2
8
+ * Version: 2.6.3
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Neumorphism
7
7
  *
8
- * Version: 2.6.2
8
+ * Version: 2.6.3
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Round
7
7
  *
8
- * Version: 2.6.2
8
+ * Version: 2.6.3
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Text
7
7
  *
8
- * Version: 2.6.2
8
+ * Version: 2.6.3
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Default
7
7
  *
8
- * Version: 2.6.2
8
+ * Version: 2.6.3
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -974,14 +974,14 @@ function tzlib_get_timezones(jsonType = false) {
974
974
  * Add to Calendar Button
975
975
  * ++++++++++++++++++++++
976
976
  *
977
- * Version: 2.6.2
977
+ * Version: 2.6.3
978
978
  * Creator: Jens Kuerschner (https://jekuer.com)
979
979
  * Project: https://github.com/add2cal/add-to-calendar-button
980
980
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
981
981
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
982
982
  *
983
983
  */
984
- const atcbVersion = '2.6.2';
984
+ const atcbVersion = '2.6.3';
985
985
  const atcbCssTemplate = {};
986
986
  const atcbIsBrowser = () => {
987
987
  if (typeof window === 'undefined') {
@@ -4960,12 +4960,19 @@ if (atcbIsBrowser()) {
4960
4960
  elem.innerHTML = template;
4961
4961
  this.attachShadow({ mode: 'open', delegateFocus: true });
4962
4962
  this.shadowRoot.append(elem.content.cloneNode(true));
4963
- this.loaded = false;
4964
- this.initialized = false;
4963
+ this.state = {
4964
+ initializing: false,
4965
+ ready: false,
4966
+ updatePending: false,
4967
+ };
4965
4968
  this.data = {};
4966
4969
  this.error = false;
4967
4970
  }
4968
4971
  async connectedCallback() {
4972
+ if (this.state.initializing || this.state.ready) {
4973
+ return;
4974
+ }
4975
+ this.state.initializing = true;
4969
4976
  const debugVal = this.getAttribute('debug');
4970
4977
  this.debug = this.hasAttribute('debug') && (!debugVal || debugVal === 'true' || debugVal === '') ? true : false;
4971
4978
  if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
@@ -4986,19 +4993,21 @@ if (atcbIsBrowser()) {
4986
4993
  console.error(e);
4987
4994
  atcb_render_debug_msg(this.shadowRoot, e);
4988
4995
  }
4989
- this.loaded = true;
4996
+ this.state.initializing = false;
4990
4997
  return;
4991
4998
  }
4992
4999
  }
4993
- this.loaded = true;
4994
5000
  await this.initButton();
5001
+ this.state.initializing = false;
5002
+ this.state.ready = true;
5003
+ return;
4995
5004
  }
4996
5005
  disconnectedCallback() {
4997
- atcb_cleanup(this.shadowRoot, this.data);
5006
+ atcb_cleanup(this.shadowRoot, this.identifier);
4998
5007
  if (this.debug) {
4999
- console.log('Add to Calendar Button "' + this.data.identifier + '" destroyed');
5008
+ console.log('Add to Calendar Button "' + this.identifier + '" destroyed');
5000
5009
  }
5001
- if (document.querySelectorAll('add-to-calendar-button').length == 0) {
5010
+ if (document.querySelectorAll('add-to-calendar-button').length === 0) {
5002
5011
  atcbBtnCount = 0;
5003
5012
  }
5004
5013
  }
@@ -5017,14 +5026,20 @@ if (atcbIsBrowser()) {
5017
5026
  })
5018
5027
  .concat(observeAdditionally);
5019
5028
  }
5020
- async attributeChangedCallback(name, oldValue, newValue) {
5021
- if (!this.loaded) {
5029
+ attributeChangedCallback(name, oldValue, newValue) {
5030
+ if (this.state.initializing || !this.state.ready) {
5022
5031
  return;
5023
5032
  }
5024
- if (this.debug && this.initialized) {
5033
+ if (this.debug && this.state.ready) {
5025
5034
  console.log(`${name}'s value has been changed from ${oldValue} to ${newValue}`);
5026
5035
  }
5027
- atcb_cleanup(this.shadowRoot, this.data);
5036
+ if (!this.updatePending) {
5037
+ this.updatePending = true;
5038
+ setTimeout(() => this.updateComponent(), 0);
5039
+ }
5040
+ }
5041
+ async updateComponent() {
5042
+ if (!this.updatePending) return;
5028
5043
  this.data = {};
5029
5044
  this.shadowRoot.querySelector('.atcb-initialized').remove();
5030
5045
  const elem = document.createElement('template');
@@ -5034,7 +5049,7 @@ if (atcbIsBrowser()) {
5034
5049
  this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
5035
5050
  if (this.data.proKey) this.proKey = this.data.proKey;
5036
5051
  } else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
5037
- this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
5052
+ this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
5038
5053
  if (this.data.proKey) this.proKey = this.data.proKey;
5039
5054
  }
5040
5055
  if (!this.data.name || this.data.name === '') {
@@ -5045,20 +5060,22 @@ if (atcbIsBrowser()) {
5045
5060
  console.error(e);
5046
5061
  atcb_render_debug_msg(this.shadowRoot, e);
5047
5062
  }
5063
+ this.updatePending = false;
5048
5064
  return;
5049
5065
  }
5050
5066
  }
5067
+ atcb_cleanup(this.shadowRoot, this.identifier);
5051
5068
  await this.initButton();
5069
+ this.updatePending = false;
5052
5070
  }
5053
5071
  async initButton() {
5054
- if (!this.initialized) {
5055
- this.initialized = true;
5072
+ if (!this.state.ready) {
5056
5073
  atcbBtnCount = atcbBtnCount + 1;
5057
5074
  }
5058
- if (this.identifier && this.identifier != '') {
5075
+ if (this.identifier && this.identifier !== '') {
5059
5076
  this.data.identifier = this.identifier;
5060
5077
  } else {
5061
- if (this.data.identifier && this.data.identifier != '') {
5078
+ if (this.data.identifier && this.data.identifier !== '') {
5062
5079
  if (!/^[\w\-_]+$/.test(this.data.identifier)) {
5063
5080
  this.data.identifier = '';
5064
5081
  if (this.debug) {
@@ -5203,10 +5220,10 @@ async function atcb_build_button(host, data) {
5203
5220
  throw new Error(e.message);
5204
5221
  }
5205
5222
  }
5206
- function atcb_cleanup(host, data) {
5223
+ function atcb_cleanup(host, identifier) {
5207
5224
  atcb_close(host);
5208
- atcb_unset_global_event_listener(data.identifier);
5209
- const schemaEl = document.getElementById('atcb-schema-' + data.identifier);
5225
+ atcb_unset_global_event_listener(identifier);
5226
+ const schemaEl = document.getElementById('atcb-schema-' + identifier);
5210
5227
  if (schemaEl) {
5211
5228
  schemaEl.remove();
5212
5229
  }
@@ -5216,7 +5233,7 @@ function atcb_cleanup(host, data) {
5216
5233
  .concat(Array.from(host.querySelectorAll('.atcb-placeholder')))
5217
5234
  .concat(Array.from(host.querySelectorAll('.atcb-button-wrapper')))
5218
5235
  .forEach((el) => el.remove());
5219
- delete atcbStates[`${data.identifier}`];
5236
+ delete atcbStates[`${identifier}`];
5220
5237
  }
5221
5238
  function atcb_set_light_mode(shadowRoot, data) {
5222
5239
  shadowRoot.host.classList.remove('atcb-dark', 'atcb-light', 'atcb-bodyScheme');
@@ -974,14 +974,14 @@ function tzlib_get_timezones(jsonType = false) {
974
974
  * Add to Calendar Button
975
975
  * ++++++++++++++++++++++
976
976
  *
977
- * Version: 2.6.2
977
+ * Version: 2.6.3
978
978
  * Creator: Jens Kuerschner (https://jekuer.com)
979
979
  * Project: https://github.com/add2cal/add-to-calendar-button
980
980
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
981
981
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
982
982
  *
983
983
  */
984
- const atcbVersion = '2.6.2';
984
+ const atcbVersion = '2.6.3';
985
985
  const atcbCssTemplate = {
986
986
  if (typeof window === 'undefined') {
987
987
  return false;
@@ -4959,12 +4959,19 @@ if (atcbIsBrowser()) {
4959
4959
  elem.innerHTML = template;
4960
4960
  this.attachShadow({ mode: 'open', delegateFocus: true });
4961
4961
  this.shadowRoot.append(elem.content.cloneNode(true));
4962
- this.loaded = false;
4963
- this.initialized = false;
4962
+ this.state = {
4963
+ initializing: false,
4964
+ ready: false,
4965
+ updatePending: false,
4966
+ };
4964
4967
  this.data = {};
4965
4968
  this.error = false;
4966
4969
  }
4967
4970
  async connectedCallback() {
4971
+ if (this.state.initializing || this.state.ready) {
4972
+ return;
4973
+ }
4974
+ this.state.initializing = true;
4968
4975
  const debugVal = this.getAttribute('debug');
4969
4976
  this.debug = this.hasAttribute('debug') && (!debugVal || debugVal === 'true' || debugVal === '') ? true : false;
4970
4977
  if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
@@ -4985,19 +4992,21 @@ if (atcbIsBrowser()) {
4985
4992
  console.error(e);
4986
4993
  atcb_render_debug_msg(this.shadowRoot, e);
4987
4994
  }
4988
- this.loaded = true;
4995
+ this.state.initializing = false;
4989
4996
  return;
4990
4997
  }
4991
4998
  }
4992
- this.loaded = true;
4993
4999
  await this.initButton();
5000
+ this.state.initializing = false;
5001
+ this.state.ready = true;
5002
+ return;
4994
5003
  }
4995
5004
  disconnectedCallback() {
4996
- atcb_cleanup(this.shadowRoot, this.data);
5005
+ atcb_cleanup(this.shadowRoot, this.identifier);
4997
5006
  if (this.debug) {
4998
- console.log('Add to Calendar Button "' + this.data.identifier + '" destroyed');
5007
+ console.log('Add to Calendar Button "' + this.identifier + '" destroyed');
4999
5008
  }
5000
- if (document.querySelectorAll('add-to-calendar-button').length == 0) {
5009
+ if (document.querySelectorAll('add-to-calendar-button').length === 0) {
5001
5010
  atcbBtnCount = 0;
5002
5011
  }
5003
5012
  }
@@ -5016,14 +5025,20 @@ if (atcbIsBrowser()) {
5016
5025
  })
5017
5026
  .concat(observeAdditionally);
5018
5027
  }
5019
- async attributeChangedCallback(name, oldValue, newValue) {
5020
- if (!this.loaded) {
5028
+ attributeChangedCallback(name, oldValue, newValue) {
5029
+ if (this.state.initializing || !this.state.ready) {
5021
5030
  return;
5022
5031
  }
5023
- if (this.debug && this.initialized) {
5032
+ if (this.debug && this.state.ready) {
5024
5033
  console.log(`${name}'s value has been changed from ${oldValue} to ${newValue}`);
5025
5034
  }
5026
- atcb_cleanup(this.shadowRoot, this.data);
5035
+ if (!this.updatePending) {
5036
+ this.updatePending = true;
5037
+ setTimeout(() => this.updateComponent(), 0);
5038
+ }
5039
+ }
5040
+ async updateComponent() {
5041
+ if (!this.updatePending) return;
5027
5042
  this.data = {};
5028
5043
  this.shadowRoot.querySelector('.atcb-initialized').remove();
5029
5044
  const elem = document.createElement('template');
@@ -5033,7 +5048,7 @@ if (atcbIsBrowser()) {
5033
5048
  this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
5034
5049
  if (this.data.proKey) this.proKey = this.data.proKey;
5035
5050
  } else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
5036
- this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
5051
+ this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
5037
5052
  if (this.data.proKey) this.proKey = this.data.proKey;
5038
5053
  }
5039
5054
  if (!this.data.name || this.data.name === '') {
@@ -5044,20 +5059,22 @@ if (atcbIsBrowser()) {
5044
5059
  console.error(e);
5045
5060
  atcb_render_debug_msg(this.shadowRoot, e);
5046
5061
  }
5062
+ this.updatePending = false;
5047
5063
  return;
5048
5064
  }
5049
5065
  }
5066
+ atcb_cleanup(this.shadowRoot, this.identifier);
5050
5067
  await this.initButton();
5068
+ this.updatePending = false;
5051
5069
  }
5052
5070
  async initButton() {
5053
- if (!this.initialized) {
5054
- this.initialized = true;
5071
+ if (!this.state.ready) {
5055
5072
  atcbBtnCount = atcbBtnCount + 1;
5056
5073
  }
5057
- if (this.identifier && this.identifier != '') {
5074
+ if (this.identifier && this.identifier !== '') {
5058
5075
  this.data.identifier = this.identifier;
5059
5076
  } else {
5060
- if (this.data.identifier && this.data.identifier != '') {
5077
+ if (this.data.identifier && this.data.identifier !== '') {
5061
5078
  if (!/^[\w\-_]+$/.test(this.data.identifier)) {
5062
5079
  this.data.identifier = '';
5063
5080
  if (this.debug) {
@@ -5202,10 +5219,10 @@ async function atcb_build_button(host, data) {
5202
5219
  throw new Error(e.message);
5203
5220
  }
5204
5221
  }
5205
- function atcb_cleanup(host, data) {
5222
+ function atcb_cleanup(host, identifier) {
5206
5223
  atcb_close(host);
5207
- atcb_unset_global_event_listener(data.identifier);
5208
- const schemaEl = document.getElementById('atcb-schema-' + data.identifier);
5224
+ atcb_unset_global_event_listener(identifier);
5225
+ const schemaEl = document.getElementById('atcb-schema-' + identifier);
5209
5226
  if (schemaEl) {
5210
5227
  schemaEl.remove();
5211
5228
  }
@@ -5215,7 +5232,7 @@ function atcb_cleanup(host, data) {
5215
5232
  .concat(Array.from(host.querySelectorAll('.atcb-placeholder')))
5216
5233
  .concat(Array.from(host.querySelectorAll('.atcb-button-wrapper')))
5217
5234
  .forEach((el) => el.remove());
5218
- delete atcbStates[`${data.identifier}`];
5235
+ delete atcbStates[`${identifier}`];
5219
5236
  }
5220
5237
  function atcb_set_light_mode(shadowRoot, data) {
5221
5238
  shadowRoot.host.classList.remove('atcb-dark', 'atcb-light', 'atcb-bodyScheme');
@@ -974,14 +974,14 @@ function tzlib_get_timezones(jsonType = false) {
974
974
  * Add to Calendar Button
975
975
  * ++++++++++++++++++++++
976
976
  *
977
- * Version: 2.6.2
977
+ * Version: 2.6.3
978
978
  * Creator: Jens Kuerschner (https://jekuer.com)
979
979
  * Project: https://github.com/add2cal/add-to-calendar-button
980
980
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
981
981
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
982
982
  *
983
983
  */
984
- const atcbVersion = '2.6.2';
984
+ const atcbVersion = '2.6.3';
985
985
  const atcbCssTemplate = {};
986
986
  const atcbIsBrowser = () => {
987
987
  if (typeof window === 'undefined') {
@@ -5652,12 +5652,19 @@ if (atcbIsBrowser()) {
5652
5652
  elem.innerHTML = template;
5653
5653
  this.attachShadow({ mode: 'open', delegateFocus: true });
5654
5654
  this.shadowRoot.append(elem.content.cloneNode(true));
5655
- this.loaded = false;
5656
- this.initialized = false;
5655
+ this.state = {
5656
+ initializing: false,
5657
+ ready: false,
5658
+ updatePending: false,
5659
+ };
5657
5660
  this.data = {};
5658
5661
  this.error = false;
5659
5662
  }
5660
5663
  async connectedCallback() {
5664
+ if (this.state.initializing || this.state.ready) {
5665
+ return;
5666
+ }
5667
+ this.state.initializing = true;
5661
5668
  const debugVal = this.getAttribute('debug');
5662
5669
  this.debug = this.hasAttribute('debug') && (!debugVal || debugVal === 'true' || debugVal === '') ? true : false;
5663
5670
  if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
@@ -5678,19 +5685,21 @@ if (atcbIsBrowser()) {
5678
5685
  console.error(e);
5679
5686
  atcb_render_debug_msg(this.shadowRoot, e);
5680
5687
  }
5681
- this.loaded = true;
5688
+ this.state.initializing = false;
5682
5689
  return;
5683
5690
  }
5684
5691
  }
5685
- this.loaded = true;
5686
5692
  await this.initButton();
5693
+ this.state.initializing = false;
5694
+ this.state.ready = true;
5695
+ return;
5687
5696
  }
5688
5697
  disconnectedCallback() {
5689
- atcb_cleanup(this.shadowRoot, this.data);
5698
+ atcb_cleanup(this.shadowRoot, this.identifier);
5690
5699
  if (this.debug) {
5691
- console.log('Add to Calendar Button "' + this.data.identifier + '" destroyed');
5700
+ console.log('Add to Calendar Button "' + this.identifier + '" destroyed');
5692
5701
  }
5693
- if (document.querySelectorAll('add-to-calendar-button').length == 0) {
5702
+ if (document.querySelectorAll('add-to-calendar-button').length === 0) {
5694
5703
  atcbBtnCount = 0;
5695
5704
  }
5696
5705
  }
@@ -5709,14 +5718,20 @@ if (atcbIsBrowser()) {
5709
5718
  })
5710
5719
  .concat(observeAdditionally);
5711
5720
  }
5712
- async attributeChangedCallback(name, oldValue, newValue) {
5713
- if (!this.loaded) {
5721
+ attributeChangedCallback(name, oldValue, newValue) {
5722
+ if (this.state.initializing || !this.state.ready) {
5714
5723
  return;
5715
5724
  }
5716
- if (this.debug && this.initialized) {
5725
+ if (this.debug && this.state.ready) {
5717
5726
  console.log(`${name}'s value has been changed from ${oldValue} to ${newValue}`);
5718
5727
  }
5719
- atcb_cleanup(this.shadowRoot, this.data);
5728
+ if (!this.updatePending) {
5729
+ this.updatePending = true;
5730
+ setTimeout(() => this.updateComponent(), 0);
5731
+ }
5732
+ }
5733
+ async updateComponent() {
5734
+ if (!this.updatePending) return;
5720
5735
  this.data = {};
5721
5736
  this.shadowRoot.querySelector('.atcb-initialized').remove();
5722
5737
  const elem = document.createElement('template');
@@ -5726,7 +5741,7 @@ if (atcbIsBrowser()) {
5726
5741
  this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
5727
5742
  if (this.data.proKey) this.proKey = this.data.proKey;
5728
5743
  } else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
5729
- this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
5744
+ this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
5730
5745
  if (this.data.proKey) this.proKey = this.data.proKey;
5731
5746
  }
5732
5747
  if (!this.data.name || this.data.name === '') {
@@ -5737,20 +5752,22 @@ if (atcbIsBrowser()) {
5737
5752
  console.error(e);
5738
5753
  atcb_render_debug_msg(this.shadowRoot, e);
5739
5754
  }
5755
+ this.updatePending = false;
5740
5756
  return;
5741
5757
  }
5742
5758
  }
5759
+ atcb_cleanup(this.shadowRoot, this.identifier);
5743
5760
  await this.initButton();
5761
+ this.updatePending = false;
5744
5762
  }
5745
5763
  async initButton() {
5746
- if (!this.initialized) {
5747
- this.initialized = true;
5764
+ if (!this.state.ready) {
5748
5765
  atcbBtnCount = atcbBtnCount + 1;
5749
5766
  }
5750
- if (this.identifier && this.identifier != '') {
5767
+ if (this.identifier && this.identifier !== '') {
5751
5768
  this.data.identifier = this.identifier;
5752
5769
  } else {
5753
- if (this.data.identifier && this.data.identifier != '') {
5770
+ if (this.data.identifier && this.data.identifier !== '') {
5754
5771
  if (!/^[\w\-_]+$/.test(this.data.identifier)) {
5755
5772
  this.data.identifier = '';
5756
5773
  if (this.debug) {
@@ -5895,10 +5912,10 @@ async function atcb_build_button(host, data) {
5895
5912
  throw new Error(e.message);
5896
5913
  }
5897
5914
  }
5898
- function atcb_cleanup(host, data) {
5915
+ function atcb_cleanup(host, identifier) {
5899
5916
  atcb_close(host);
5900
- atcb_unset_global_event_listener(data.identifier);
5901
- const schemaEl = document.getElementById('atcb-schema-' + data.identifier);
5917
+ atcb_unset_global_event_listener(identifier);
5918
+ const schemaEl = document.getElementById('atcb-schema-' + identifier);
5902
5919
  if (schemaEl) {
5903
5920
  schemaEl.remove();
5904
5921
  }
@@ -5908,7 +5925,7 @@ function atcb_cleanup(host, data) {
5908
5925
  .concat(Array.from(host.querySelectorAll('.atcb-placeholder')))
5909
5926
  .concat(Array.from(host.querySelectorAll('.atcb-button-wrapper')))
5910
5927
  .forEach((el) => el.remove());
5911
- delete atcbStates[`${data.identifier}`];
5928
+ delete atcbStates[`${identifier}`];
5912
5929
  }
5913
5930
  function atcb_set_light_mode(shadowRoot, data) {
5914
5931
  shadowRoot.host.classList.remove('atcb-dark', 'atcb-light', 'atcb-bodyScheme');
package/dist/atcb.js CHANGED
@@ -974,14 +974,14 @@ function tzlib_get_timezones(jsonType = false) {
974
974
  * Add to Calendar Button
975
975
  * ++++++++++++++++++++++
976
976
  *
977
- * Version: 2.6.2
977
+ * Version: 2.6.3
978
978
  * Creator: Jens Kuerschner (https://jekuer.com)
979
979
  * Project: https://github.com/add2cal/add-to-calendar-button
980
980
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
981
981
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
982
982
  *
983
983
  */
984
- const atcbVersion = '2.6.2';
984
+ const atcbVersion = '2.6.3';
985
985
  const atcbCssTemplate = {
986
986
  if (typeof window === 'undefined') {
987
987
  return false;
@@ -5651,12 +5651,19 @@ if (atcbIsBrowser()) {
5651
5651
  elem.innerHTML = template;
5652
5652
  this.attachShadow({ mode: 'open', delegateFocus: true });
5653
5653
  this.shadowRoot.append(elem.content.cloneNode(true));
5654
- this.loaded = false;
5655
- this.initialized = false;
5654
+ this.state = {
5655
+ initializing: false,
5656
+ ready: false,
5657
+ updatePending: false,
5658
+ };
5656
5659
  this.data = {};
5657
5660
  this.error = false;
5658
5661
  }
5659
5662
  async connectedCallback() {
5663
+ if (this.state.initializing || this.state.ready) {
5664
+ return;
5665
+ }
5666
+ this.state.initializing = true;
5660
5667
  const debugVal = this.getAttribute('debug');
5661
5668
  this.debug = this.hasAttribute('debug') && (!debugVal || debugVal === 'true' || debugVal === '') ? true : false;
5662
5669
  if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
@@ -5677,19 +5684,21 @@ if (atcbIsBrowser()) {
5677
5684
  console.error(e);
5678
5685
  atcb_render_debug_msg(this.shadowRoot, e);
5679
5686
  }
5680
- this.loaded = true;
5687
+ this.state.initializing = false;
5681
5688
  return;
5682
5689
  }
5683
5690
  }
5684
- this.loaded = true;
5685
5691
  await this.initButton();
5692
+ this.state.initializing = false;
5693
+ this.state.ready = true;
5694
+ return;
5686
5695
  }
5687
5696
  disconnectedCallback() {
5688
- atcb_cleanup(this.shadowRoot, this.data);
5697
+ atcb_cleanup(this.shadowRoot, this.identifier);
5689
5698
  if (this.debug) {
5690
- console.log('Add to Calendar Button "' + this.data.identifier + '" destroyed');
5699
+ console.log('Add to Calendar Button "' + this.identifier + '" destroyed');
5691
5700
  }
5692
- if (document.querySelectorAll('add-to-calendar-button').length == 0) {
5701
+ if (document.querySelectorAll('add-to-calendar-button').length === 0) {
5693
5702
  atcbBtnCount = 0;
5694
5703
  }
5695
5704
  }
@@ -5708,14 +5717,20 @@ if (atcbIsBrowser()) {
5708
5717
  })
5709
5718
  .concat(observeAdditionally);
5710
5719
  }
5711
- async attributeChangedCallback(name, oldValue, newValue) {
5712
- if (!this.loaded) {
5720
+ attributeChangedCallback(name, oldValue, newValue) {
5721
+ if (this.state.initializing || !this.state.ready) {
5713
5722
  return;
5714
5723
  }
5715
- if (this.debug && this.initialized) {
5724
+ if (this.debug && this.state.ready) {
5716
5725
  console.log(`${name}'s value has been changed from ${oldValue} to ${newValue}`);
5717
5726
  }
5718
- atcb_cleanup(this.shadowRoot, this.data);
5727
+ if (!this.updatePending) {
5728
+ this.updatePending = true;
5729
+ setTimeout(() => this.updateComponent(), 0);
5730
+ }
5731
+ }
5732
+ async updateComponent() {
5733
+ if (!this.updatePending) return;
5719
5734
  this.data = {};
5720
5735
  this.shadowRoot.querySelector('.atcb-initialized').remove();
5721
5736
  const elem = document.createElement('template');
@@ -5725,7 +5740,7 @@ if (atcbIsBrowser()) {
5725
5740
  this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
5726
5741
  if (this.data.proKey) this.proKey = this.data.proKey;
5727
5742
  } else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
5728
- this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
5743
+ this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
5729
5744
  if (this.data.proKey) this.proKey = this.data.proKey;
5730
5745
  }
5731
5746
  if (!this.data.name || this.data.name === '') {
@@ -5736,20 +5751,22 @@ if (atcbIsBrowser()) {
5736
5751
  console.error(e);
5737
5752
  atcb_render_debug_msg(this.shadowRoot, e);
5738
5753
  }
5754
+ this.updatePending = false;
5739
5755
  return;
5740
5756
  }
5741
5757
  }
5758
+ atcb_cleanup(this.shadowRoot, this.identifier);
5742
5759
  await this.initButton();
5760
+ this.updatePending = false;
5743
5761
  }
5744
5762
  async initButton() {
5745
- if (!this.initialized) {
5746
- this.initialized = true;
5763
+ if (!this.state.ready) {
5747
5764
  atcbBtnCount = atcbBtnCount + 1;
5748
5765
  }
5749
- if (this.identifier && this.identifier != '') {
5766
+ if (this.identifier && this.identifier !== '') {
5750
5767
  this.data.identifier = this.identifier;
5751
5768
  } else {
5752
- if (this.data.identifier && this.data.identifier != '') {
5769
+ if (this.data.identifier && this.data.identifier !== '') {
5753
5770
  if (!/^[\w\-_]+$/.test(this.data.identifier)) {
5754
5771
  this.data.identifier = '';
5755
5772
  if (this.debug) {
@@ -5894,10 +5911,10 @@ async function atcb_build_button(host, data) {
5894
5911
  throw new Error(e.message);
5895
5912
  }
5896
5913
  }
5897
- function atcb_cleanup(host, data) {
5914
+ function atcb_cleanup(host, identifier) {
5898
5915
  atcb_close(host);
5899
- atcb_unset_global_event_listener(data.identifier);
5900
- const schemaEl = document.getElementById('atcb-schema-' + data.identifier);
5916
+ atcb_unset_global_event_listener(identifier);
5917
+ const schemaEl = document.getElementById('atcb-schema-' + identifier);
5901
5918
  if (schemaEl) {
5902
5919
  schemaEl.remove();
5903
5920
  }
@@ -5907,7 +5924,7 @@ function atcb_cleanup(host, data) {
5907
5924
  .concat(Array.from(host.querySelectorAll('.atcb-placeholder')))
5908
5925
  .concat(Array.from(host.querySelectorAll('.atcb-button-wrapper')))
5909
5926
  .forEach((el) => el.remove());
5910
- delete atcbStates[`${data.identifier}`];
5927
+ delete atcbStates[`${identifier}`];
5911
5928
  }
5912
5929
  function atcb_set_light_mode(shadowRoot, data) {
5913
5930
  shadowRoot.host.classList.remove('atcb-dark', 'atcb-light', 'atcb-bodyScheme');