pollcatch 2.5.5 → 2.5.6

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/package.json +2 -2
  2. package/pc.js +20 -12
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pollcatch",
3
3
  "private": false,
4
- "version": "2.5.5",
4
+ "version": "2.5.6",
5
5
  "type": "module",
6
6
  "main": "pc.js",
7
7
  "module": "pc.js",
@@ -25,4 +25,4 @@
25
25
  ],
26
26
  "author": "David Lin <david@pollcatch.com>",
27
27
  "homepage": "https://www.pollcatch.com"
28
- }
28
+ }
package/pc.js CHANGED
@@ -1280,20 +1280,28 @@ class Zo {
1280
1280
  */
1281
1281
  applyWidgetAttributes(t) {
1282
1282
  if (!t) return;
1283
- const o = typeof t.attributes == "object" && t.attributes !== null && !Array.isArray(t.attributes) ? t.attributes : t, r = this.host, s = r;
1284
- for (const [i, a] of Object.entries(o)) {
1285
- if (a == null) continue;
1286
- if (i === "options" && typeof a == "string") {
1287
- const n = Be(a);
1288
- r.options = n.map((d) => ({
1289
- value: d,
1290
- label: d,
1291
- icon: r.type === $.reaction ? d : void 0
1292
- })), g.debug("Applied widget options as property:", n);
1283
+ const o = typeof t.attributes == "object" && t.attributes !== null && !Array.isArray(t.attributes) ? t.attributes : t, r = this.host, s = r, i = /* @__PURE__ */ new Set();
1284
+ for (let a = 0; a < s.attributes.length; a++) {
1285
+ const l = s.attributes[a];
1286
+ l && l.name !== "type" && l.name !== "options" && l.name !== "initialized" && i.add(l.name);
1287
+ }
1288
+ for (const [a, l] of Object.entries(o)) {
1289
+ if (l == null) continue;
1290
+ if (a === "options" && typeof l == "string") {
1291
+ const d = Be(l);
1292
+ r.options = d.map((p) => ({
1293
+ value: p,
1294
+ label: p,
1295
+ icon: r.type === $.reaction ? p : void 0
1296
+ })), g.debug("Applied widget options as property:", d);
1297
+ continue;
1298
+ }
1299
+ const n = a.replace(/([A-Z])/g, "-$1").toLowerCase();
1300
+ if (i.has(n)) {
1301
+ g.debug(`Skipping server attribute "${n}" — overridden by inline attribute`);
1293
1302
  continue;
1294
1303
  }
1295
- const l = i.replace(/([A-Z])/g, "-$1").toLowerCase();
1296
- typeof a == "boolean" ? a ? s.setAttribute(l, "") : s.removeAttribute(l) : typeof a == "object" ? s.setAttribute(l, JSON.stringify(a)) : s.setAttribute(l, String(a)), g.debug(`Applied widget attribute: ${l}=${a}`);
1304
+ typeof l == "boolean" ? l ? s.setAttribute(n, "") : s.removeAttribute(n) : typeof l == "object" ? s.setAttribute(n, JSON.stringify(l)) : s.setAttribute(n, String(l)), g.debug(`Applied widget attribute: ${n}=${l}`);
1297
1305
  }
1298
1306
  }
1299
1307
  /**