Closed Bug 1854104 Opened 2 years ago Closed 4 months ago

Consider CSS attr() fallback

Categories

(DevTools :: Inspector: Rules, enhancement, P3)

enhancement

Tracking

(relnote-firefox -, firefox149 fixed)

RESOLVED FIXED
149 Branch
Tracking Status
relnote-firefox --- -
firefox149 --- fixed

People

(Reporter: canadahonk, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-needed)

Attachments

(2 files)

Support for CSS attr()'s fallback (eg attr(foo, "fallback")) is being implemented and shipped in Bug 1448248. It should display okay in DevTools currently but it could possibly be improved (needs investigation). No other browsers implement or ship it at this time.

Spec: https://drafts.csswg.org/css-values-5/#attr-notation

We could do what is done for var() and display the value not being used in a "disabled"-grey color
CanadaHonk, can we detect that in javascript that the fallback is used?

Flags: needinfo?(oj)

No unfortunately, the spec doesn't add anything to DOM/etc exposing any fallback info afaik. I would be happy to add it but would likely need an upstream spec issue deciding how best to do so.

Flags: needinfo?(oj)

Well, we can detect it using element.hasAttribute(...) right?

Priority: -- → P3
Component: Inspector → Inspector: Rules
Blocks: 2003735

This adds unmatched class to the attribute name or the fallback depending
on the existence of the attribute (provided via a getAttributeValue option.

In #parseMatchingParens, we know also return whitespace tokens so we can
reconstruct the authored value properly from it.

Test cases are added in browser_outputparser.js to cover this.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/d7d86bc85ab7 https://hg.mozilla.org/integration/autoland/rev/67683182d95c [devtools] Parse attr() function in OutputParser. r=devtools-reviewers,jdescottes. https://github.com/mozilla-firefox/firefox/commit/ea4858b781e0 https://hg.mozilla.org/integration/autoland/rev/e056a92f93f3 [devtools] Strike through unused attr() parameter in Rules view. r=devtools-reviewers,jdescottes
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
Blocks: 2014734
Blocks: 2014751
QA Whiteboard: [qa-triage-done-c150/b149]

Similarily to bug 2011646, I believe this should be mentioned at least in the dev release notes for Firefox 149 and maybe even in the general release notes together with the addition in 2011646.

Sebastian

Flags: needinfo?(nchevobbe)
Keywords: dev-doc-needed
Regressions: 2023648

(In reply to Sebastian Zartner [:sebo] from comment #8)

Similarily to bug 2011646, I believe this should be mentioned at least in the dev release notes for Firefox 149 and maybe even in the general release notes together with the addition in 2011646.

A little late now, though I'll try it anyway.

[Why is this notable]: New DevTools feature
[Affects Firefox for Android]: no
[Suggested wording]: In the Rules view, the unused value within the attr() function is now crossed out and there's a tooltip shown displaying the referenced HTML attribute's value.
[Links (documentation, blog post, etc)]:
Bug 2011646

Flags: needinfo?(nchevobbe)

Thanks Sebo (and sorry for dropping the ball here)

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: