Skip to content

fix: wrap Observer in IIFE to prevent redeclaration on View Transitions#57

Merged
FenjuFu merged 1 commit into
mainfrom
fix-js-error
Jul 15, 2026
Merged

fix: wrap Observer in IIFE to prevent redeclaration on View Transitions#57
FenjuFu merged 1 commit into
mainfrom
fix-js-error

Conversation

@dongjiang1989

@dongjiang1989 dongjiang1989 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:

Fixes #

Special notes for reviewers:

Changes

Fixed

  • Observer Redeclaration on View Transitions: const Observer in BasicScripts.astro top-level is:inline script caused SyntaxError: Identifier 'Observer' has already been declared when Astro client router swapped pages — wrapped in IIFE (() => { ... })() to create function scope

Changelog

  • Added CI auto-update workflow fix (ADMIN_PAT) and Observer IIFE fix entries to [Unreleased]

Test plan

  • npm run check passes (astro check, eslint, prettier) — 0 errors, 0 warnings, 0 hints
  • npm run build completes successfully
  • Navigate between pages via client-side routing — no SyntaxError in console

The `const Observer` in BasicScripts.astro was declared at the top level of an
is:inline script. When Astro's client router swaps pages, the script re-executes
and tries to redeclare Observer, causing a SyntaxError. Wrapping in an IIFE
creates a function scope that avoids the collision. Also update CHANGELOG with
CI workflow fix and this JS error fix.

Signed-off-by: dongjiang <dongjiang1989@126.com>
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
website Ready Ready Preview, Comment Jul 15, 2026 6:33am

@FenjuFu FenjuFu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the whitespace-ignored diff is a pure IIFE wrap with no logic change, and confirmed the ADMIN_PAT changelog entry matches the current workflows. All checks green. LGTM.

@FenjuFu
FenjuFu merged commit c9581cd into main Jul 15, 2026
12 checks passed
@dongjiang1989
dongjiang1989 deleted the fix-js-error branch July 15, 2026 07:08
@dongjiang1989
dongjiang1989 restored the fix-js-error branch July 17, 2026 06:58
@dongjiang1989
dongjiang1989 deleted the fix-js-error branch July 17, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants