Skip to content

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

Open
@civvic

Description

@civvic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions