Martin Winkler published a package that polyfills Element.matchContainer to get notified in script when a Container Query matches/unmatches. Under the hood, it uses a StyleObserver.
A rather geeky/technical weblog, est. 2001, by Bramus
StyleObserver: Element.matchContainer()@function + CSS if() = 🤯attr() gets an upgrade<custom-ident> and <dashed-ident> values with ident()CSSNestedDeclarations is coming to all browsers to improve CSS Nesting!