Closed Bug 1946199 Opened 5 months ago Closed 5 months ago

DevTools shows incorrect applied CSS in Styles panel when using layers and !important

Categories

(DevTools :: Inspector: Rules, defect)

Firefox 135
defect

Tracking

(firefox137 fixed)

RESOLVED FIXED
137 Branch
Tracking Status
firefox137 --- fixed

People

(Reporter: chriskirknielsen, Assigned: nchevobbe)

References

()

Details

Attachments

(2 files)

Attached image demo.png

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0

Steps to reproduce:

  1. Create an element with an inline style set to important
  2. Create a <style> with a layer that sets the same property as inline, but to a different value, also using important (e.g.: <p style="color: blue !important"> and @layer { p { color: red !important; }}`)
  3. Inspect the element via DevTools and compare the Styles panel and Computed panel reported values

Live demo: https://codepen.io/chriskirknielsen/pen/yyBdXPo?editors=0100

Actual results:

The Styles panel and Computed panel report a different "winning" style value.

Expected results:

The Styles and Computed panels should report the same style value.

The Bugbug bot thinks this bug should belong to the 'DevTools::Inspector' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Inspector
Product: Firefox → DevTools

Thanks for the report. I thought we handled those cases correctly in Bug 1824652, but I guess I missed this

Status: UNCONFIRMED → NEW
Component: Inspector → Inspector: Rules
Ever confirmed: true

From https://www.w3.org/TR/css-cascade-5/#style-attr:

declarations that are attached directly to an element (such as the contents
of a style attribute) rather than indirectly mapped by means of a style rule
selector take precedence over declarations the same importance that are mapped
via style rule.

this comes before the layer ordering, so an important property in the style
attribute will always win against an important property in a layer rule (which
differs from "regular" rules, where important property in layer wins over
important property not in a layer)

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6840deb4efa9 [devtools] Fix overridden declaration on element style with similar declaration in layer. r=devtools-reviewers,jdescottes.
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: