Skip to content

Commit

Permalink
Fix NPE (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp authored Apr 2, 2024
1 parent 9c5b2c6 commit 9e8532a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-pots-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro-vtbot": patch
---

Fixes a bug accessing an attribute of null when linking to view transition pages outside the starlight site.
6 changes: 2 additions & 4 deletions components/starlight/StarlightConnector.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export interface Props {}
function closeMobileMenu() {
if (document.body.hasAttribute('data-mobile-menu-expanded')) {
document.body
.querySelector('starlight-menu-button')!
.closest('nav')!
.dispatchEvent(
.querySelector('starlight-menu-button')?.closest('nav')?.dispatchEvent(
new KeyboardEvent('keyup', {
key: 'Escape',
code: 'Escape',
Expand All @@ -35,7 +33,7 @@ export interface Props {}
}

function markMainFrameForReplacementSwap(doc: Document) {
doc.body.querySelector('div.main-frame')!.setAttribute('data-vtbot-replace', 'main');
doc.body.querySelector('div.main-frame')?.setAttribute('data-vtbot-replace', 'main');
}

function setTransitionScope(e: TransitionBeforePreparationEvent) {
Expand Down

0 comments on commit 9e8532a

Please sign in to comment.