selectorcoverage

command
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Command selectorcoverage reports which of a stylesheet's selectors never match a document.

selectorcoverage -selectors rules.txt < page.html
selectorcoverage -css site.css < page.html

It cannot check every selector, and saying so is most of the point. lol-html matches the subset a streaming rewriter can decide when it sees a start tag, so anything needing what follows - :last-child, :only-child, :empty - is rejected, along with the sibling combinators, :is/:where/:has, pseudo-elements and state selectors like :hover. Real stylesheets are full of those.

So every selector lands in one of three buckets: matched, never matched, or not checkable with the reason. A tool that quietly dropped the third would report coverage it had not measured.

Each checkable selector costs a handler, and matching cost grows with the number registered, on every element. A stylesheet with thousands of rules is worth splitting across runs rather than registering all at once.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL