@lightningjs/blits 2.8.5 → 2.8.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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/router/router.js +10 -2
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/router/router.js
CHANGED
|
@@ -342,7 +342,9 @@ export const navigate = async function () {
|
|
|
342
342
|
? viewState.overrideOptions.keepAlive
|
|
343
343
|
: this.previousRoute.options && this.previousRoute.options.keepAlive
|
|
344
344
|
|
|
345
|
-
// cache the page when it's as 'keepAlive' instead of destroying
|
|
345
|
+
// cache the page when it's marked as 'keepAlive' instead of destroying,
|
|
346
|
+
// but only when navigating forward AND the route is in history (so it can be restored on back)
|
|
347
|
+
let cached = false
|
|
346
348
|
if (
|
|
347
349
|
viewState.navigatingBack === false &&
|
|
348
350
|
keepAlive === true &&
|
|
@@ -354,6 +356,7 @@ export const navigate = async function () {
|
|
|
354
356
|
if (historyItem !== undefined) {
|
|
355
357
|
historyItem.view = oldView
|
|
356
358
|
historyItem.focus = viewState.previousFocus
|
|
359
|
+
cached = true
|
|
357
360
|
}
|
|
358
361
|
}
|
|
359
362
|
|
|
@@ -361,8 +364,13 @@ export const navigate = async function () {
|
|
|
361
364
|
* 1. Navigating forward, and the previous route is not configured with "keep alive" set to true.
|
|
362
365
|
* 2. Navigating back, and the previous route is configured with "keep alive" set to true.
|
|
363
366
|
* 3. Navigating back, and the previous route is not configured with "keep alive" set to true.
|
|
367
|
+
* 4. Navigating forward, keepAlive is true but caching failed (no inHistory or no history
|
|
368
|
+
* item) — destroy to prevent orphaned components leaking in the eventsMap.
|
|
364
369
|
*/
|
|
365
|
-
if (
|
|
370
|
+
if (
|
|
371
|
+
(this.previousRoute.options && (keepAlive !== true || viewState.navigatingBack === true)) ||
|
|
372
|
+
!cached
|
|
373
|
+
) {
|
|
366
374
|
oldView.destroy()
|
|
367
375
|
oldView = null
|
|
368
376
|
}
|