Skip to content
Menu

unmatched-host-selector

Reports a variant that tests a shadow host through the elements around it.

On this page

This rule reports a variant stack that tests a shadow host through the elements around it, such as host:in-[.page]: or host:group-hover:. A selector in a shadow tree cannot read those elements, so the rule never matches.

Reported

style.css("host:in-[.page]:block");unmatched-host-selector: `:where(:is(.page)) :host` cannot match the shadow host; pass the state down with a custom property

Fixed

style.css("[:host(.page)]:block");

How to fix

  • Add a class or an attribute to the host, and test it inside :host(), as in the example.
  • Set a custom property on the outer element, and read it on the host with --if(). Custom properties inherit into a shadow tree.

Rule settings

PresetSeverity
recommendedwarn
strictdeny
stylisticoff

Configure lint to change the severity or options.

Type to search the documentation.