Adding declaration in Rules view adds it after any nested declaration
Categories
(DevTools :: Inspector: Rules, defect, P2)
Tracking
(firefox137 verified, firefox138 verified)
People
(Reporter: nchevobbe, Assigned: nchevobbe)
References
Details
Attachments
(2 files)
Steps to reproduce
- Navigate to
data:text/html,<meta charset=utf8><style>body { color: red; &:where(*) { color: blue; } }</style>Hello
- Open the inspector
- In the Rules view, add a
color: gold
declaration in thebody
rule, belowcolor: red
Expected results
The text on the page stays blue as there's another (nested) rule declared later
Actual results
The text on the page turns gold.
If we look at the styleeditor, we can see that the declaration is added after the nested declaration
body {
color: red;
&:where(*) {
color: blue;
}
color: gold;
}
This is not what's expected, we should get
body {
color: red;
color: gold;
&:where(*) {
color: blue;
}
}
as a result, this creates another rule, so when the rule is refreshed you'll see the new declaration in two different rules:
body {
{
color: gold;
}
}
body {
&:where(*) {
color: blue;
}
}
body {
color: red;
color: gold;
}
note that this could have a similar cause than Bug 1946439, and both bugs might be fixed with a single patch
Assignee | ||
Comment 1•1 month ago
|
||
Updated•1 month ago
|
Assignee | ||
Comment 2•1 month ago
|
||
Create a dummy rule with the content of the rule being modified so we can
check if it has a nested rule. In such case, we can then get the location
of the nested rule so we can insert the added text in the correct position.
A few unit test cases are added to make sure the RuleRewriter does handle
nested rules properly.
Updated•1 month ago
|
Comment 4•1 month ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/e43f18d07ffa
https://hg.mozilla.org/mozilla-central/rev/850b58556292
Issue is reproducible on a 2025-02-06 Firefox Nightly build on Windows 10.
Verified as fixed on Firefox Nightly 138.0a1 and Firefox 137.0b2 on Windows 10, Ubuntu 22, macOS 14.
Description
•