The issue has been solved
Apparently 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 has funded $80.00 to this issue.
posted by IssueHuntBot almost 6 years ago
posted by janat08 almost 6 years ago 
we could potentially proxy document addeventlisteners
posted by janat08 almost 6 years ago
Or can we listen to history changes and remove & re-apply all listeners? Or would delegated events be a more efficient fix?
posted by danedavid almost 6 years ago
Or can we listen to history changes and remove & re-apply all listeners
That's kinda complicated because events are attached when creating the dom (e.g. <a onClick={handler}>
), so taking these two pieces apart seems messy, also because each feature's init
function is generally not re-run when the ajax page changes.
I think a good way to go about solving this issue is figuring out why this is happening;
- How can the dom exist without the listeners?
- What's the GitHub code that takes care of this behavior?
- How does GitHub handle their own events? They might be all delegate events
posted by bfred-it almost 6 years ago
I inspected the page, Github's click targets seem to have a data-hydro-click
attribute with a JS object as its value, which contains details regarding the event. I couldn't find anything else on that attribute though; maybe it's some internal library that they use?
I think our way to solve this would be by using delegated events in the app, maybe using @bfred-it 's library delegate-it
. What's you take?
posted by danedavid almost 6 years ago
I think our way to solve this would be by using delegated events in the app, maybe using @bfred-it 's library delegate-it
. What's you take?
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.
posted by bfred-it over 5 years ago
posted by issuehunt-app[bot] about 5 years ago