Repository navigation
--computed: rule coverage for style rules only one side has - #140
Merged
Merged
Conversation
A clean run couldn't show that a changed rule ever applied. With --computed, each side's style rules (document.styleSheets, so renderdiff's adopted CSS is left out) are compared as Chrome serializes them, origin and url() hashes normalized. Rules only one side has are grouped by stylesheet and enclosing at-rules, and each shot records how many elements they could style there. The summary lists groups that matched nothing anywhere, then ones that matched on some shots only (a breakpoint's two sides); all-matched groups are only counted. Cross-origin sheets are listed once in meta.unreadableSheets. Closes #121 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tent Stripped states and pseudo-elements now read as :where(*), so ::selection or :focus-visible alone is matched instead of nothing. A <style> is named inline# plus a hash of its text, so a block inlined into every page is one group. The page is walked once; node keys, diffs and groups the rows, and a second evaluate only counts matches. Coverage runs after the snapshot's race, with its own timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #121.
Where each #121 item stands
report --markdownalready gives Before/After shots for every width, clean ones included.:nth-of-type, so one that moves among siblings with the same tag and classes still re-keys them. The docs say so.failed.User-facing changes
With
--computed, a new block appears aftercomputed::How rules are compared
document.styleSheets. renderdiff's own CSS is adopted, so it is never read.url()are normalized.rgb()notation changes are no change, butmin-width:→width >=is.How matches are counted
<style>is namedinline#plus a hash of its text, so a block inlined into every page is one group, and a page's own block stays separate.@media/@supportsmust hold and a selector must match.What the block lists
, all matched). The block shows at most 20 lines.rules: no style rule differs between the sideswhen, once parsed, both sides' rules are the same.Known limits
:hover/:focus/:active/:visitedand pseudo-elements match any element (so::selection {}counts as matched), and@containercounts as holding.:checked,:target,[open], classes added by script, and<link media=print>count as unmatched unless the shot is in that state.meta.unreadableSheetsand left out of the comparison.Fields
computed.rulesper result ({ side, sheet, conditions, rules, elements }),summary.rules({ side, sheet, conditions, rules, matched, unmatched }), andmeta.unreadableSheets.mergerecomputessummary.rulesand unionsmeta.unreadableSheets.computed.rulesis left out.--computed) do no extra page work.Tests
A new
rulesguard-rail fixture renders the same on both sides. Its left side rewrites@media (min-width: 960px)to(width >= 960px), adds a.bubblerule that matches nothing, adds state-only::selectionand:focus-visiblerules (which must count as matched), and changes only notation inrgb()and the hash in aurl(). The test runs at 960 and 959 and asserts:summary.rules;The
rgb()andurl()changes must produce no group.A base-vs-base run of metabase.com
/and/docs/latest/givesrules: no style rule differs between the sides, with 6 cross-origin sheets listed per side.🤖 Generated with Claude Code