Refactor Has-variant CSS serialization to use existing serialize_selector_list helper
Categories
(Core :: CSS Parsing and Computation, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox148 | --- | fixed |
People
(Reporter: nabeyang, Assigned: nabeyang)
Details
Attachments
(1 file, 1 obsolete file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Steps to reproduce:
In parser.rs, the Has(ref list) arm was manually iterating over the list of RelativeSelectors to call selector.to_css(dest) with comma+space separation.
I replaced this manual loop with a call to the existing helper function serialize_selector_list, passing list.iter().map(|rel| &rel.selector). This unifies the serialization logic for selector lists and reduces duplicated code.
Actual results:
Currently, there are essentially two different implementations for serializing selector-lists with identical semantics: one for Is/Where/Negation variants (via serialize_selector_list), and one custom loop for Has.
This duplication increases maintenance burden and risks subtle inconsistency. For example, if formatting rules (spacing, comma separation) are ever adjusted in serialize_selector_list, the Has branch might not follow the update, leading to inconsistent CSS output.
Expected results:
Selector-list serialization should be implemented uniformly across all relevant variants; in particular, the Has variant should reuse the existing serialize_selector_list helper just like other variants. This ensures consistency, reduces duplicated code, and simplifies future maintenance.
The change should not alter any functional behavior (CSS output stays identical), but makes the code easier to maintain and less error-prone.
| Assignee | ||
Comment 1•2 months ago
|
||
Replace manual loop in the Has(ref list) arm with a call to the existing
serialize_selector_list helper. This removes duplication and ensures
consistent selector-list serialization across variants (Is/Where/Negation/Has),
without changing any functional output.
No behavioral change expected; CSS output remains identical. The refactoring
improves maintainability and reduces chances of formatting divergence in
future.
Updated•2 months ago
|
Comment 3•2 months ago
|
||
| bugherder | ||
| Assignee | ||
Comment 4•2 months ago
|
||
The documentation comments for combinator_at_match_order and
combinator_at_parse_order described index directions opposite to their
actual implementations.
This change updates the Rustdoc comments so that the documented index
semantics (zero-indexed from the left or right) match the behavior of
each function.
Comment 5•2 months ago
|
||
Comment on attachment 9532855 [details]
Bug 2004688 - Fix swapped index direction comments for combinator accessors r=dshin
Revision D276342 was moved to bug 2005876. Setting attachment 9532855 [details] to obsolete.
Updated•1 month ago
|
Description
•