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

Reset history.pushState after patching #68

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

dsrominiyi
Copy link

With each navigation, the original pushState implementation is increasingly nested within patched versions of itself.

tomcru added a commit to tomcru/holy-loader that referenced this pull request Feb 26, 2024
The previous implementation of patching the History API methods (pushState and replaceState) was causing them to increasingly nest within patched versions of themselves.

To fix this, a new flag `isHistoryPatched` was introduced to prevent redundant patching. The `stopProgressOnHistoryUpdate` function now checks if the flag is already set before applying the patch. Additionally, the flag is set to `true` after the patching is done to ensure it is only applied once.

Reference: TheSGJ/nextjs-toploader#68
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