From b999d595d6cd1f203c23cc2e1c8ee4d1eecbc753 Mon Sep 17 00:00:00 2001 From: dongjiang Date: Wed, 15 Jul 2026 14:25:15 +0800 Subject: [PATCH] fix: wrap Observer in IIFE to prevent redeclaration on View Transitions 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 --- CHANGELOG.md | 5 + src/components/common/BasicScripts.astro | 208 ++++++++++++----------- 2 files changed, 110 insertions(+), 103 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfb5193..f1245e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ All notable changes to this project will be documented in this file. - **Hugging Face Icon Asset**: Download official Hugging Face SVG logo to `src/assets/images/hugging-face.svg`; replace inline placeholder SVGs in `ProjectCard.astro` and `[slug].astro` with `` +### Fixed + +- **CI Auto-Update Workflows**: Scheduled workflows (`Update Project Stats`, `Update Contributors`) failed with GH013 because `GITHUB_TOKEN` cannot bypass the "Protect default branch" ruleset — replaced with `ADMIN_PAT` secret (repo admin added to ruleset bypass list) +- **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 + ## [0.3.0] - 2026-07-03 ### Added diff --git a/src/components/common/BasicScripts.astro b/src/components/common/BasicScripts.astro index f13b273..ea9aa78 100644 --- a/src/components/common/BasicScripts.astro +++ b/src/components/common/BasicScripts.astro @@ -223,133 +223,135 @@ import { translations } from '~/utils/translations';