From bbaa5bf22184de3349eccc3f497dfe70c9a76fe1 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 28 Nov 2025 18:15:09 -0800 Subject: [PATCH] fix: add null/undefined guards for array access and navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MasteryDisplay.svelte: Use optional chaining for split()[0] array access - formatRingStat().split('+')[0] -> split('+')[0]?.trim() ?? '' - formatEarringStat().split('+')[0] -> split('+')[0]?.trim() ?? '' - TeamView.svelte: Same fix for formatAxSkill().split('+')[0] - +layout.svelte: Add null guards for 'to' parameter and 'mainContent' in callback - Check !to before accessing to.url - Re-check !mainContent inside requestAnimationFrame callback Fixes "Object is possibly 'undefined'" and "is possibly 'null'" errors with noUncheckedIndexedAccess: true and strict null checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/lib/components/sidebar/details/TeamView.svelte | 2 +- .../sidebar/modifications/MasteryDisplay.svelte | 8 ++++---- src/routes/+layout.svelte | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/components/sidebar/details/TeamView.svelte b/src/lib/components/sidebar/details/TeamView.svelte index 5dcbcea8..bb5d25e5 100644 --- a/src/lib/components/sidebar/details/TeamView.svelte +++ b/src/lib/components/sidebar/details/TeamView.svelte @@ -88,7 +88,7 @@ {#each weapon.ax as axSkill} {/if} @@ -54,7 +54,7 @@ {#if variant === 'detailed'} - {formatRingStat(ring.modifier, ring.strength, locale).split('+')[0].trim()} + {formatRingStat(ring.modifier, ring.strength, locale).split('+')[0]?.trim() ?? ''} +{ring.strength}{getRingStat(ring.modifier)?.suffix || ''} @@ -81,7 +81,7 @@ {#if iconUrl} {formatEarringStat(earring.modifier, {/if} @@ -89,7 +89,7 @@ {#if variant === 'detailed'} - {formatEarringStat(earring.modifier, earring.strength, locale, characterElement).split('+')[0].trim()} + {formatEarringStat(earring.modifier, earring.strength, locale, characterElement).split('+')[0]?.trim() ?? ''} +{earring.strength}{getElementalizedEarringStat(earring.modifier, characterElement, locale)?.suffix || ''} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 2e5253e2..7b066550 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -58,10 +58,11 @@ // Handle scroll restoration or reset after navigation afterNavigate(({ from, to, type }) => { - if (!mainContent) return; + if (!mainContent || !to) return; // Use requestAnimationFrame to ensure DOM has updated requestAnimationFrame(() => { + if (!mainContent) return; const key = to.url.pathname + to.url.search; // Only restore scroll for browser back/forward navigation