fix: restore translations after browser history navigation - #792
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extend the existing navigation lifecycle in
main.user.jsso a completed/restored page refreshesState.currentURLand 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.cjsusing the repository's existingnode:test,node:vm, and real-source function loading pattern fromtest/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