Skip to content

css: an invalid selector invalidates its whole rule - #480

Open
fschutt wants to merge 1 commit into
masterfrom
claude/nice-bardeen-hjit6y
Open

fschutt wants to merge 1 commit into
masterfrom
claude/nice-bardeen-hjit6y

Conversation

@fschutt

@fschutt fschutt commented Sep 30, 2026

Copy link
Copy Markdown
Owner

When a selector list contained a part the parser could not handle (an unknown pseudo-class/-element, an unknown type selector, a malformed attribute selector), new_from_str_inner warned and skipped only that token, keeping the rest of the selector. The rule then applied to a WIDER selector than written: .word::selection { color: #000 } became .word { color: #000 }, p:unknown became p, and div unknowntag became div + dangling descendant combinator.

Per Selectors 4 section 3.7 an invalid selector makes the whole rule invalid (for a selector list, every selector in it). Track that while the selector list is read; an invalid rule opens a dropped nesting level, so neither its declarations nor any nested rule are emitted and the SkippedRule warning is kept.

Claude-Session: https://claude.ai/code/session_01GPPrSydyY9syEfGC74Kch2

When a selector list contained a part the parser could not handle (an
unknown pseudo-class/-element, an unknown type selector, a malformed
attribute selector), new_from_str_inner warned and skipped only that
token, keeping the rest of the selector. The rule then applied to a
WIDER selector than written: `.word::selection { color: #000 }` became
`.word { color: #000 }`, `p:unknown` became `p`, and
`div unknowntag` became `div ` + dangling descendant combinator.

Per Selectors 4 section 3.7 an invalid selector makes the whole rule
invalid (for a selector list, every selector in it). Track that while
the selector list is read; an invalid rule opens a dropped nesting
level, so neither its declarations nor any nested rule are emitted and
the SkippedRule warning is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GPPrSydyY9syEfGC74Kch2
fschutt pushed a commit to fschutt/pdfocr that referenced this pull request Sep 30, 2026
…tches

printpdf comes from fschutt/printpdf#287 (text honours color alpha) as a
git dependency; azul-css from fschutt/azul#480 (invalid selectors drop
their rule) via [patch.crates-io]. azul-core/-layout stay on 0.0.16:
azul master's azul-layout does not build with printpdf's feature set.
Cargo.lock is committed so the exact upstream commits are pinned, and CI
builds with --locked. patches/ is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GPPrSydyY9syEfGC74Kch2
fschutt added a commit that referenced this pull request Oct 2, 2026
fschutt added a commit that referenced this pull request Oct 2, 2026
PR #480 added NestingLevel::invalid; this branch's nested-@-rule push (the
source-order change) had no initializer for it. It is reached only when the
parent rule and the selector are valid - the invalid check runs first and
continues - so false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WyGP18BMbfHvnTRYqNVjbP

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants