-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Support the <attr-type> production #4030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Although MDN reports this as unsupported on all browsers, this codepen demonstrates that it does seem to work on Chrome at least as of v133, so we should support it (probably by declaring |
All right, the proposal has landed. It does involve a breaking change, but it's also a CSS support feature, so I'll give it two weeks for public comment before we implement the deprecation. |
It's been two weeks without comment, so I'm going to mark this as accepted and start work on implementing phase 1. |
Hello! Will the implementation also allow using attr color: rgba(attr(data-color type(<color>)), 0.7); It currently throws an error with the workaround: $color: attr(data-color type(#{"<color>"})) is not a color. |
No. The two-argument |
Uh oh!
There was an error while loading. Please reload this page.
Deprecation
%
as a stand-alone expression dart-sass#2540)attr()
function syntax sass-site#1340)Final Changes
CSS has an
attr()
function which can have a nestedtype()
function call for an argument. Thetype()
function accepts a "syntax argument" which is passed as an angle bracketed string, as in<number>
.https://developer.mozilla.org/en-US/docs/Web/CSS/attr
Example of valid CSS (I think):
This throws an error when passed to Sass as a
.scss
file (playground):Workaround
One workaround that can be used is quoting the "syntax" value, and using interpolation or
string.unquote()
to unquote it. For example:The text was updated successfully, but these errors were encountered: