css-scope-inline icon indicating copy to clipboard operation
css-scope-inline copied to clipboard

Shouldn't observer be a singleton as intended?

Open civvic opened this issue 11 months ago • 0 comments

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.

civvic avatar Dec 02 '24 13:12 civvic