viconic-react-icons 1.1.4 → 1.1.5

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/dist/index.js CHANGED
@@ -54,12 +54,21 @@ var import_react = __toESM(require("react"));
54
54
  }
55
55
  const _origCEDefine = customElements.define.bind(customElements);
56
56
  customElements.define = function(name, cls, opts) {
57
- if (name === "viconic-icon" && cls && cls.prototype && cls.prototype._u) {
58
- const origU = cls.prototype._u;
59
- cls.prototype._u = function() {
60
- if (this.classList.contains("svg-loaded")) return;
61
- return origU.call(this);
62
- };
57
+ if (name === "viconic-icon" && cls && cls.prototype) {
58
+ if (cls.prototype._u) {
59
+ const origU = cls.prototype._u;
60
+ cls.prototype._u = function() {
61
+ if (this.classList.contains("svg-loaded")) return;
62
+ return origU.call(this);
63
+ };
64
+ }
65
+ if (cls.prototype.connectedCallback) {
66
+ const origCC = cls.prototype.connectedCallback;
67
+ cls.prototype.connectedCallback = function() {
68
+ if (this.classList.contains("svg-loaded")) return;
69
+ return origCC.call(this);
70
+ };
71
+ }
63
72
  }
64
73
  return _origCEDefine(name, cls, opts);
65
74
  };
package/dist/index.mjs CHANGED
@@ -19,12 +19,21 @@ import React, { useEffect, useRef } from "react";
19
19
  }
20
20
  const _origCEDefine = customElements.define.bind(customElements);
21
21
  customElements.define = function(name, cls, opts) {
22
- if (name === "viconic-icon" && cls && cls.prototype && cls.prototype._u) {
23
- const origU = cls.prototype._u;
24
- cls.prototype._u = function() {
25
- if (this.classList.contains("svg-loaded")) return;
26
- return origU.call(this);
27
- };
22
+ if (name === "viconic-icon" && cls && cls.prototype) {
23
+ if (cls.prototype._u) {
24
+ const origU = cls.prototype._u;
25
+ cls.prototype._u = function() {
26
+ if (this.classList.contains("svg-loaded")) return;
27
+ return origU.call(this);
28
+ };
29
+ }
30
+ if (cls.prototype.connectedCallback) {
31
+ const origCC = cls.prototype.connectedCallback;
32
+ cls.prototype.connectedCallback = function() {
33
+ if (this.classList.contains("svg-loaded")) return;
34
+ return origCC.call(this);
35
+ };
36
+ }
28
37
  }
29
38
  return _origCEDefine(name, cls, opts);
30
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viconic-react-icons",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Viconic Smart Icons loader for React — supports Kit and 200k+ system icons",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -52,13 +52,23 @@
52
52
  // so it skips elements that Smart Loader has already handled.
53
53
  const _origCEDefine = customElements.define.bind(customElements);
54
54
  customElements.define = function(name, cls, opts) {
55
- if (name === 'viconic-icon' && cls && cls.prototype && cls.prototype._u) {
56
- const origU = cls.prototype._u;
57
- cls.prototype._u = function() {
58
- // If Smart Loader already injected SVG, don't touch this element
59
- if (this.classList.contains('svg-loaded')) return;
60
- return origU.call(this);
61
- };
55
+ if (name === 'viconic-icon' && cls && cls.prototype) {
56
+ // Patch _u() to skip elements already handled by Smart Loader
57
+ if (cls.prototype._u) {
58
+ const origU = cls.prototype._u;
59
+ cls.prototype._u = function() {
60
+ if (this.classList.contains('svg-loaded')) return;
61
+ return origU.call(this);
62
+ };
63
+ }
64
+ // Patch connectedCallback to also guard svg-loaded
65
+ if (cls.prototype.connectedCallback) {
66
+ const origCC = cls.prototype.connectedCallback;
67
+ cls.prototype.connectedCallback = function() {
68
+ if (this.classList.contains('svg-loaded')) return;
69
+ return origCC.call(this);
70
+ };
71
+ }
62
72
  }
63
73
  return _origCEDefine(name, cls, opts);
64
74
  };