Ramonda

dom-writes

This fails the run. Where it is wrong about your code, // ramonda-check-ignore <reason> on the line says so, and the reason is printed on every run.

Reported when a component writes the document — document.body.classList.add(…) and its family — where render() could have said it.

A class, an attribute or a piece of text written this way is a SECOND copy of state the component already holds: it has to be kept in step by hand, cleaned up when the component goes away, and remembered by whoever adds the next handler that touches it. Say it in render() and let the stylesheet read it — html:has(.drawer-open) reaches the document from a class a descendant renders, so even the page itself can be styled from state.

A COMMAND is not this and is not reported: scrollIntoView(), focus(), select() and getBoundingClientRect() have no declarative form. Nor is an element you created yourself, or one held in a ref — that one is your own.

Next