@pageboard/html 0.16.8 → 0.16.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.
- package/elements/sitemap.js +0 -1
- package/package.json +1 -1
- package/ui/consent.js +18 -2
- package/ui/embed.js +5 -5
package/elements/sitemap.js
CHANGED
package/package.json
CHANGED
package/ui/consent.js
CHANGED
|
@@ -70,15 +70,30 @@ class HTMLElementConsent extends Page.create(HTMLFormElement) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
Page.constructor.prototype.consents = function (name, val) {
|
|
74
|
+
const { storage } = this.scope;
|
|
75
|
+
const key = "consent." + name;
|
|
76
|
+
if (val === null) {
|
|
77
|
+
storage.remove(key);
|
|
78
|
+
} else if (val !== undefined) {
|
|
79
|
+
storage.set(key, val ? "yes" : "no");
|
|
80
|
+
} else {
|
|
81
|
+
const str = storage.get(key);
|
|
82
|
+
if (str == "yes") return true;
|
|
83
|
+
else if (str == "no") return false;
|
|
84
|
+
else return null;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
73
88
|
Page.constructor.prototype.consent = function (listener, ask) {
|
|
74
89
|
const { consent } = listener.constructor;
|
|
75
90
|
if (!consent) {
|
|
76
91
|
console.warn("Expected a static consent field", listener);
|
|
77
92
|
return;
|
|
78
93
|
}
|
|
79
|
-
const cur = this.
|
|
94
|
+
const cur = this.consents(consent);
|
|
80
95
|
if (cur == null || ask) {
|
|
81
|
-
this.
|
|
96
|
+
this.consents(consent, HTMLElementConsent.ask(this, consent));
|
|
82
97
|
}
|
|
83
98
|
this.chain('consent', listener);
|
|
84
99
|
};
|
|
@@ -89,6 +104,7 @@ Page.define(`element-consent`, HTMLElementConsent, 'form');
|
|
|
89
104
|
Page.paint(state => {
|
|
90
105
|
state.finish(() => {
|
|
91
106
|
if (!HTMLElementConsent.explicits.size) {
|
|
107
|
+
// last chance for implicit consents
|
|
92
108
|
state.copy().runChain('consent');
|
|
93
109
|
}
|
|
94
110
|
});
|
package/ui/embed.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class HTMLElementEmbed extends Page.Element {
|
|
2
|
-
static consent = "
|
|
2
|
+
static consent = "marketing";
|
|
3
3
|
static defaults = {
|
|
4
4
|
src: null,
|
|
5
5
|
query: null,
|
|
@@ -25,12 +25,12 @@ class HTMLElementEmbed extends Page.Element {
|
|
|
25
25
|
this.#meta(state);
|
|
26
26
|
}
|
|
27
27
|
consent(state) {
|
|
28
|
-
const consent = state.
|
|
29
|
-
this.classList.toggle('denied', consent
|
|
30
|
-
this.classList.toggle('waiting', consent
|
|
28
|
+
const consent = state.consents(this.constructor.consent);
|
|
29
|
+
this.classList.toggle('denied', consent === false);
|
|
30
|
+
this.classList.toggle('waiting', consent === null);
|
|
31
31
|
|
|
32
32
|
const iframe = this.querySelector('iframe');
|
|
33
|
-
if (consent
|
|
33
|
+
if (consent !== true) {
|
|
34
34
|
iframe.src = "";
|
|
35
35
|
return;
|
|
36
36
|
}
|