@muonic/muon 0.0.2-beta.45 → 0.0.2-beta.47

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.47](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.46...v0.0.2-beta.47) (2023-10-03)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * checkavailabe cache ([d780dc9](https://github.com/centrica-engineering/muon/commit/d780dc921cf32c377690b7dfdfe1ce3031850ab3))
11
+
12
+ ### [0.0.2-beta.46](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.45...v0.0.2-beta.46) (2023-09-26)
13
+
5
14
  ### [0.0.2-beta.45](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.44...v0.0.2-beta.45) (2023-09-18)
6
15
 
7
16
  ### [0.0.2-beta.44](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.43...v0.0.2-beta.44) (2023-09-15)
@@ -24,11 +24,14 @@ export class SVGLoaderDirective extends AsyncDirective {
24
24
  try {
25
25
  cacheAvailable = 'caches' in self;
26
26
  cache = cacheAvailable && await caches?.open(SVG_CONFIG_CACHE);
27
- const cacheData = await cache.match(url);
27
+ const cacheData = cacheAvailable && await cache?.match(url);
28
28
 
29
29
  response = cache && cacheData ? cacheData : undefined;
30
+
31
+ if (!cacheAvailable) {
32
+ console.info('cache not available');
33
+ }
30
34
  } catch (error) {
31
- console.info('cache not available');
32
35
  console.info(error);
33
36
  }
34
37
 
@@ -60,17 +63,18 @@ export class SVGLoaderDirective extends AsyncDirective {
60
63
  threshold: 0.01,
61
64
  rootMargin: '150px'
62
65
  };
66
+ const observe = parts.parentNode;
63
67
 
64
68
  const io = new IntersectionObserver((entries) => {
65
69
  /* eslint-disable consistent-return */
66
70
  return entries.forEach((entry) => {
67
71
  if (entry.intersectionRatio > 0) {
72
+ io.unobserve(observe);
68
73
  return resolve(this.render(attributes));
69
74
  }
70
75
  });
71
76
  }, options);
72
77
 
73
- const observe = parts.parentNode;
74
78
  io.observe(observe);
75
79
  });
76
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-beta.45",
3
+ "version": "0.0.2-beta.47",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -87,3 +87,12 @@ snapshots["icon caches not available"] =
87
87
  `;
88
88
  /* end snapshot icon caches not available */
89
89
 
90
+ snapshots["icon broken caches"] =
91
+ `<div
92
+ aria-hidden="true"
93
+ class="arrow-right icon"
94
+ >
95
+ </div>
96
+ `;
97
+ /* end snapshot icon broken caches */
98
+
@@ -182,6 +182,21 @@ describe('icon', () => {
182
182
  expect(el.innerText.trim()).to.equal('', 'has no light dom');
183
183
  });
184
184
 
185
+ it('broken caches', async () => {
186
+ self.caches.open = () => {
187
+ throw new TypeError('Failed to execute \'open\' on \'CacheStorage\': 1 argument required, but only 0 present.');
188
+ };
189
+
190
+ const consoleWarn = sinon.stub(console, 'info');
191
+ const el = await fixture(html`<${tag}></${tag}>`);
192
+
193
+ await awaitLoading(el);
194
+ await defaultChecks(el);
195
+
196
+ expect(consoleWarn.args[0][0].toString()).to.equal('TypeError: Failed to execute \'open\' on \'CacheStorage\': 1 argument required, but only 0 present.', 'console info shows that cache is not available');
197
+ expect(consoleWarn.args.length).to.equal(1, 'info shows 1 messages');
198
+ });
199
+
185
200
  it('caches not available', async () => {
186
201
  delete self.caches; // replicate caches API not being available
187
202
 
@@ -192,6 +207,6 @@ describe('icon', () => {
192
207
  await defaultChecks(el);
193
208
 
194
209
  expect(consoleWarn.args[0]).to.deep.equal(['cache not available'], 'console info shows that cache is not available');
195
- expect(consoleWarn.args.length).to.equal(2, 'info shows 2 messages');
210
+ expect(consoleWarn.args.length).to.equal(1, 'info shows 1 messages');
196
211
  });
197
212
  });