u2ui 1.5.14 → 1.5.15

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/el/ico/ico.js +6 -7
  2. package/package.json +1 -1
package/el/ico/ico.js CHANGED
@@ -131,13 +131,11 @@ async function loadSvgString(url) {
131
131
  }
132
132
  }
133
133
 
134
- const svg = await loadCached(url);
135
- // temporary cache svg
136
-
137
134
  // external element
138
- if (hash) { // todo, cache the svgDoc?
139
- const parser = new DOMParser();
140
- const svgDoc = parser.parseFromString(svg, "image/svg+xml");
135
+ if (hash) {
136
+ url.hash = '';
137
+ const svgDoc = await (cachedDocuments[url] ??= loadCached(url).then(svg =>
138
+ new DOMParser().parseFromString(svg, "image/svg+xml")));
141
139
  const element = svgDoc.getElementById(hash);
142
140
  if (element) {
143
141
  return element.outerHTML;
@@ -147,10 +145,11 @@ async function loadSvgString(url) {
147
145
  }
148
146
 
149
147
  // external document
150
- return svg;
148
+ return loadCached(url);
151
149
  }
152
150
 
153
151
  const cachedRequests = {};
152
+ const cachedDocuments = {};
154
153
 
155
154
  async function loadCached(url) {
156
155
  return cachedRequests[url] ??= fetch(url, {cache: "force-cache"}).then(res => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u2ui",
3
- "version": "1.5.14",
3
+ "version": "1.5.15",
4
4
  "description": "HTML Advanced: More Capabilities, Same Feel, Same Simplicity",
5
5
  "keywords": ["web-components","pattern-library","component-library","ui-toolkit","design-system"],
6
6
  "author": "Tobias Buschor",