Old events don't work on history.back()
See original GitHub issueApparently GitHub caches but regenerates the DOM between ajax loads. This means that our markup is still there, but no events are attached to it.
I think in many cases they still work because we use global delegated events, but it doesn’t where we use onClick
and addEventListener
I don’t think it’s a consequence of #1175 because before it, the old button would still be there and inactive.
To reproduce the bug:
- Visit https://github.com/sindresorhus/refined-github/issues
- Visit the “Code” tab
- Press the “Back” browser button
- Click the “Open all (issue)” link above the issue list. It doesn’t work anymore
This is rather annoying, the only solution I can think of is to only use delegated events. Not great.
IssueHunt Summary
fregante has been rewarded.
Backers (Total: $80.00)
- issuehunt ($80.00)
Submitted pull Requests
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
IssueHunt has been backed by the following sponsors. Become a sponsor
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
history.back() Not Working When Navigating Back on Same ...
I would like to implement a function that ensures prompting back on all browsers to stay within a given domain, and avoid skipping...
Read more >History.back() - Web APIs - MDN Web Docs - Mozilla
This method is asynchronous. Add a listener for the popstate event in order to determine when the navigation has completed.
Read more >History go() Method - W3Schools
The history.go() method loads a URL (page) from the history list. The history.go() method only works if the page exist in the history...
Read more >Browser Back Button does not trigger window.onbeforeunload
If I use router.back() and as documentation states as of now is equivalent of window.history.back() , on an event where previous page is...
Read more >Page: DOMContentLoaded, load, beforeunload, unload
DOMContentLoaded event – DOM is ready, so the handler can lookup DOM nodes, ... preventDefault() doesn't work from a beforeunload handler.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Delegated events would indeed work, but that means using global delegated events for everything. It’s a solution but not what we’re looking for, there would be too many click listeners and eventually that’s gonna slow you down.
@sindresorhus has rewarded $72.00 to @fregante. See it on IssueHunt