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

Shouldn't observer be a singleton as intended? #21

Open
civvic opened this issue Dec 2, 2024 · 0 comments
Open

Shouldn't observer be a singleton as intended? #21

civvic opened this issue Dec 2, 2024 · 0 comments

Comments

@civvic
Copy link

civvic commented Dec 2, 2024

In your (awesome) code:

window.cssScope ??= new MutationObserver(mutations => { // Allow 1 observer.
    ...
}).observe(document.documentElement, {childList: true, subtree: true})

It seems you want the observer to be a singleton, but .observe() is not chainable, so window.cssScope always ends up as undefined.

Probably in normal HTML pages it's not important, but I'm playing with HTMX/FastHTML in Notebooks and it's easy to get several observers running simultaneasly.

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

1 participant