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

Click-listeners are added multiple times to enhanced blocks #15

Open
1 task done
derpondus opened this issue Dec 2, 2024 · 3 comments
Open
1 task done

Click-listeners are added multiple times to enhanced blocks #15

derpondus opened this issue Dec 2, 2024 · 3 comments

Comments

@derpondus
Copy link
Contributor

derpondus commented Dec 2, 2024

Description

It goes for the timestamp and the spoiler block:
grafik
grafik

This is a problem if an even number of listeners is fired, as all of them are bubbling and the state is not changed.

TODO

Figure out what causes this

Can I work on this?

  • Yes
@martian0x80
Copy link
Owner

I can only recreate this by navigating back and forth between pages on Crunchyroll.

I can't recreate this after adding a simple check to prevent adding multiple listeners.

comment.querySelectorAll("span.crunchy-comments-spoiler-block").forEach((spoiler) => {
	if (spoiler.dataset.hasEventListener === "true") return
	spoiler.addEventListener("click", () => {
		spoiler.classList.toggle("revealed")
	})
	spoiler.dataset.hasEventListener = "true"
})

Can you test if this works?

@derpondus
Copy link
Contributor Author

I am not able to reproduce it anymore :D

Seems to be fixed 👍

ps.: sorry this took me so long, I was ill and then swamped with work afterward 😅

@derpondus
Copy link
Contributor Author

Oh no, I just encountered a case in which the eventlistener was missing entirely...

grafik
(no "event" tag next to the element)

I don't remember what exactly I did, but the has-event-listener value is true, so something can become inconsistent with this fix.
(I believe, I just clicked on continue to watch on the main page, but there has to be something else to it.)

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

No branches or pull requests

2 participants