-
Notifications
You must be signed in to change notification settings - Fork 144
Color names not working with ExpandShorthands #510
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
Hi @BenPayton, Thanks for the report <3 The shorthand There are some restrictions on the ordering of values in the We'll need to investigate this further. If you are able to delve into the code to find out why what's going wrong is, that would be greatly appreciated, but no worries if not. |
Thanks. A quick look at RuleSet\DeclarationBlock\expandBackgroundShorthand() shows it sets an array of default properties in |
Your analysis makes sense.
On reflection, I think that is correct behaviour. I often forget that the shorthand syntax replaces all longhand properties, including any that are not provided (with default values being used for those missing, and no 'cascade' for them). Apologies.
Yes. Looking at The Longer term, we are considering introducing classes to represent specific types of named values (e.g. #353), instead of using In the meantime, we are backporting bugfixes to an 8.5.x branch. Would you be willing to have a crack at a couple of pull requests (PRs) to fix these two problems? (I think the Thanks. |
Thank you for the response. Agreed on the default background rules, that should be correct behavior. It makes sense both I don't think I will have the time commitment to contribute unfortunately, so I will leave it to someone more capable. Thanks again for your help. |
I think if we were to recognize named colors and parse them into |
IMHO
Similarly, I am not sure whether we support expanding |
I think border-style has a higher chance of a new value being added to the spec than a new named color being introduced. The last named color added was rebeccapurple in honor of Rebecca Meyer and that was already in violation of the long-standing rule against adding new named colors. |
I agree. I've just created #512 for this. |
So I'd suggest closing this as "sorry, won't fix anymore". Would you be okay with this, @sabberworm @JakeQZ ? |
Fine by me. Though I would still like to pursue support for parsing named colors as |
I agree and have created #514 for this. |
Agree with all this. Though it would be good for the existing (incomplete) implementation of expanding shorthands to be made clearly available for anyone who wants to use it as a basis for providing that functionality in a separate package (or just in their own project) - I've commented to that effect in #512. |
I'm using this parser in a project to optimize and pull data from hundreds of old CSS files, most of which make use of only hex and named colors.
CSS example:
After
expandShorthands()
If a selector has shorthand border or background properties that use color names, border colors become border-style values and background colors are dropped entirely and replaced with "transparent".
My current workaround for this is to use a custom class to parse the value strings and convert any color names to hex values before running
expandShorthands()
.The text was updated successfully, but these errors were encountered: