Implement CSS attr(<attr-name>, <attr-fallback>)
Categories
(Core :: CSS Parsing and Computation, enhancement, P3)
Tracking
()
People
(Reporter: sebo, Assigned: canadahonk)
References
(Blocks 1 open bug, )
Details
(Keywords: dev-doc-complete)
Attachments
(1 file)
Updated•7 years ago
|
Comment 1•6 years ago
|
||
Tests
background: attr(data-test color);
http://w3c-test.org/css/css-values/attr-color-valid.html
width: attr(data-test length);
http://w3c-test.org/css/css-values/attr-length-valid-zero-nofallback.html
width: attr(data-test length);
http://w3c-test.org/css/css-values/attr-length-valid.html
width: attr(data-test px);
http://w3c-test.org/css/css-values/attr-px-valid.html
Updated•3 years ago
|
| Assignee | ||
Comment 2•2 years ago
|
||
Implemented support for a fallback in CSS attr funcs
(attr(<attr-name>, <attr-fallback>))
Spec: https://drafts.csswg.org/css-values-5/#attr-notation
WIP. Todo:
- Parse fallback into variable
- Use fallback in C++
- Add WPT tests
| Assignee | ||
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 5•2 years ago
|
||
| bugherder | ||
| Assignee | ||
Comment 7•2 years ago
|
||
Release Note Request (optional, but appreciated)
[Why is this notable]: New CSS feature supported
[Affects Firefox for Android]: Yes
[Suggested wording]: The CSS attr() function now supports a fallback parameter (eg attr(foobar, "Default value")). First browser to implement, and ship.
[Links (documentation, blog post, etc)]: None yet.
Comment 8•2 years ago
|
||
Added to 119 beta release notes (https://www.mozilla.org/en-US/firefox/119.0beta/releasenotes/) as well as the Draft release notes for 119
Updated•2 years ago
|
Comment 9•2 years ago
|
||
Comment 10•2 months ago
|
||
I don't know if this was intentional, but I don't think that this works.
Consider the following:
<style>
p { background-color: green; padding: attr(data-padding px, 10px); margin: 20px; }
</style>
<p>This has the default padding.</p>
<p data-padding=0>This has no padding.</p>
<p data-padding=30>This has triple padding.</p>
I see no padding in Firefox. Not 10px of padding. Chromium is fine.
The following works, which suggests that this is probably a parsing thing.
<style>
div::after { content: attr(data-after, "nothing"); }
</style>
<div>The fox says:</div>
<div data-after="yo">The fox says:</div>
| Reporter | ||
Comment 11•2 months ago
•
|
||
Firefox still only supports attr() in the content property, at the moment. See bug 435426 and the ones blocking it for the extensions to it and letting it apply to other properties. (The one for your example is bug 1871823.)
Sebastian
Comment 12•2 months ago
|
||
This works, but we only currently support attr() on the content property. Bug 435426 which is being worked on at the moment will fix your test case.
Comment 13•2 months ago
|
||
Hah, midaired, thx Sebastian :)
Description
•