Closed Bug 1704179 Opened 3 years ago Closed 3 years ago

Warn for attempts to combine `:host` pseudoclass in ways that never select anything

Categories

(Core :: CSS Parsing and Computation, defect)

Desktop
All
defect

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: Gijs, Assigned: emilio)

Details

Attachments

(1 file, 1 obsolete file)

Things like div:host or :host:hover can never work, you want :host(div) and :host(:hover). This is somewhat unintuitive as div:before or window:root or :root:-moz-lwtheme and so on all work - it'd be useful if the non-working :host ones tripped a CSS parsing warning so web/Firefox devs know what they're doing.

Emilio says:

I don't think it should be hard. Somewhere around here we could do something like if reporting_css_errors && has_useless_selector { context.error_reporter.log_css_error(...) } or something
it's a pretty hot code-path I guess, that might be an issue, but since we disable error reporting by default hopefully the extra branch doesn't matter

Flags: needinfo?(emilio)
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Flags: needinfo?(emilio)

Maybe I should just remove the rule? It's effect is very subtle :-)

Attachment #9215102 - Attachment is obsolete: true
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7f01fb5e6cfa
Add a CSS error to the console when using non-featureless :host selectors. r=boris
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: