Web Components

webc/host-hidden

Shadow styles that give :host a display also add :host([hidden]) { display none }, or the hidden attribute stops working.

umiarkowanastatycznefe-web-components

Dlaczego

A custom element is display: inline by default, so components set :host { display: block }. That author rule beats the browser's own [hidden] { display: none }, so <acme-panel hidden> stays visible: menus that should be closed show, and screen reader users hear content that should be gone.

Poprawka

Next to every :host { display: … }, add :host([hidden]) { display: none; }. Keep the default display as the first rule of the component's styles so it is easy to find.

Przykłady

/* bad */
:host { display: block; }
/* good */
:host { display: block; }
:host([hidden]) { display: none; }

Źródła

Fakty

Identyfikator
webc/host-hidden
Waga
umiarkowana
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
jsx html css scss
Uczy jej skill
fe-web-components Web components and Lit
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain webc/host-hidden