@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.
@@ -1,6 +1,5 @@
1
1
  exports.sitemap = {
2
2
  group: "block",
3
3
  icon: '<i class="sitemap icon"></i>',
4
- menu: 'link',
5
4
  html: `<element-sitemap>DEPRECATED</element-sitemap>`
6
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageboard/html",
3
- "version": "0.16.8",
3
+ "version": "0.16.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "repository": {
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.scope.storage.get(consent);
94
+ const cur = this.consents(consent);
80
95
  if (cur == null || ask) {
81
- this.scope.storage.set(consent, HTMLElementConsent.ask(this, consent));
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 = "consent.embed";
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.scope.storage.get(this.constructor.consent);
29
- this.classList.toggle('denied', consent == "no");
30
- this.classList.toggle('waiting', consent == null);
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 != "yes") {
33
+ if (consent !== true) {
34
34
  iframe.src = "";
35
35
  return;
36
36
  }