Skip to content

fix: restore translations after browser history navigation - #792

Open
mvanhorn wants to merge 1 commit into
maboloshi:gh-pagesfrom
mvanhorn:fix/684-github-chinese-history-navigation
Open

fix: restore translations after browser history navigation#792
mvanhorn wants to merge 1 commit into
maboloshi:gh-pagesfrom
mvanhorn:fix/684-github-chinese-history-navigation

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Extend the existing navigation lifecycle in main.user.js so a completed/restored page refreshes State.currentURL and page configuration, disconnects the old translation observer, traverses the current body using the existing translation and exclusion logic, reconnects observation to that body, and runs the existing title/selector/description work. Browser back/forward navigation, whether initiated by mouse side buttons or browser toolbar buttons, leaves GitHub content untranslated.

Add test/issue-684-regression.test.cjs using the repository's existing node:test, node:vm, and real-source function loading pattern from test/issue-785-regression.test.cjs. Load the actual production registration and navigation functions with fake event targets, timers, bodies, and a recording MutationObserver; avoid a separate implementation of the navigation algorithm in tests; Reproduce the demonstrated failure first: initialize observation on body A, switch from repository content to an issues route and body B, dispatch the registered Turbo event, and assert that configuration matches the destination, old observation is disconnected, body B is traversed, and subsequent mutations of B reach translation. Execute this scenario for each listed userscript; it must fail before the runtime change.

Fixes #684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

使用鼠标侧键或浏览器顶部按钮进行前进后退后翻译失效

1 participant