saasufy-components 9.5.1 → 9.5.2

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.
Files changed (2) hide show
  1. package/oauth-link.js +20 -7
  2. package/package.json +1 -1
package/oauth-link.js CHANGED
@@ -9,6 +9,10 @@ class OAuthLink extends HTMLElement {
9
9
  this.handleSlotChangeEvent = () => {
10
10
  this.renderItem();
11
11
  };
12
+
13
+ this.handleClickEvent = () => {
14
+ this.updateState();
15
+ };
12
16
  }
13
17
 
14
18
  static get observedAttributes() {
@@ -34,10 +38,12 @@ class OAuthLink extends HTMLElement {
34
38
 
35
39
  this.render();
36
40
  this.shadowRoot.addEventListener('slotchange', this.handleSlotChangeEvent);
41
+ this.addEventListener('click', this.handleClickEvent);
37
42
  }
38
43
 
39
44
  disconnectedCallback() {
40
45
  this.shadowRoot.removeEventListener('slotchange', this.handleSlotChangeEvent);
46
+ this.removeEventListener('click', this.handleClickEvent);
41
47
  }
42
48
 
43
49
  renderItem() {
@@ -67,12 +73,7 @@ class OAuthLink extends HTMLElement {
67
73
  viewportNode.innerHTML = itemString;
68
74
  }
69
75
 
70
- render() {
71
- if (this.code) {
72
- this.shadowRoot.innerHTML = '';
73
- return;
74
- }
75
-
76
+ updateState() {
76
77
  let provider = this.getAttribute('provider');
77
78
  if (!provider) {
78
79
  throw new Error('The provider attribute of oauth-link was not specified');
@@ -93,10 +94,22 @@ class OAuthLink extends HTMLElement {
93
94
  } else {
94
95
  stateList = []
95
96
  }
96
- this.state = `${provider}-${generateRandomHexString(stateSize)}`;
97
+ if (this.provider !== provider) {
98
+ this.state = `${provider}-${generateRandomHexString(stateSize)}`;
99
+ this.provider = provider;
100
+ }
97
101
  stateList.unshift(this.state);
98
102
 
99
103
  storage.setItem(storageKey, stateList.join(','));
104
+ }
105
+
106
+ render() {
107
+ if (this.code) {
108
+ this.shadowRoot.innerHTML = '';
109
+ return;
110
+ }
111
+
112
+ this.updateState();
100
113
 
101
114
  this.shadowRoot.innerHTML = `
102
115
  <slot name="item"></slot>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "9.5.1",
3
+ "version": "9.5.2",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {