Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE #59

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading