@techninja/clearstack 0.3.26 → 0.3.28
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/README.md
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="docs/clearstack_logo.
|
|
2
|
+
<img src="docs/clearstack_logo.svg" alt="Clearstack" width="520">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
# Clearstack
|
|
6
|
-
|
|
7
5
|
A no-build web component framework specification — and its working proof — built entirely through LLM-human collaboration.
|
|
8
6
|
|
|
9
7
|
## Why This Exists
|
|
@@ -381,6 +381,54 @@ This is especially important when render depends on external mutable state
|
|
|
381
381
|
(e.g. an in-memory cache object) that the property change is meant to
|
|
382
382
|
signal. Without the reset, the component renders with stale external state.
|
|
383
383
|
|
|
384
|
+
#### Router Cache Poisons Boolean Flags Across Reconnects
|
|
385
|
+
|
|
386
|
+
When a routed view has a boolean property used as a fallback/error flag,
|
|
387
|
+
the router cache can poison it across reconnects. If the flag is ever set
|
|
388
|
+
to `true` (e.g. a failed fetch), the cached value persists. On the next
|
|
389
|
+
navigation to that view, `connect` runs but the property is already `true`
|
|
390
|
+
from cache — even though the default is `false`:
|
|
391
|
+
|
|
392
|
+
```javascript
|
|
393
|
+
// ❌ BAD — if fallback was ever true, it stays true on reconnect
|
|
394
|
+
export default define({
|
|
395
|
+
tag: 'my-view',
|
|
396
|
+
data: {
|
|
397
|
+
value: undefined,
|
|
398
|
+
connect(host, _key, invalidate) {
|
|
399
|
+
loadData(host).then(() => invalidate());
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
fallback: false, // default is false, but cache may hold true
|
|
403
|
+
render: ({ data, fallback }) => {
|
|
404
|
+
if (fallback) return html`<p>Error</p>`; // stuck here forever
|
|
405
|
+
// ...
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// ✅ GOOD — reset the flag in connect before the async load
|
|
410
|
+
export default define({
|
|
411
|
+
tag: 'my-view',
|
|
412
|
+
data: {
|
|
413
|
+
value: undefined,
|
|
414
|
+
connect(host, _key, invalidate) {
|
|
415
|
+
host.fallback = false; // clear stale cache
|
|
416
|
+
loadData(host).then(() => invalidate());
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
fallback: false,
|
|
420
|
+
render: ({ data, fallback }) => {
|
|
421
|
+
if (fallback) return html`<p>Error</p>`;
|
|
422
|
+
// ...
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
The general rule: any boolean flag that gates render output and is set
|
|
428
|
+
by an async `connect` flow should be explicitly reset at the top of
|
|
429
|
+
`connect`. This is especially common with fetch-or-fallback patterns
|
|
430
|
+
where the fallback path sets the flag to `true` on network errors.
|
|
431
|
+
|
|
384
432
|
#### `router.backUrl()` Serializes All Parent Properties
|
|
385
433
|
|
|
386
434
|
`router.backUrl()` encodes the parent view's property values into query
|