postcss / autoprefixer

Parse CSS and add vendor prefixes to rules by Can I Use
https://twitter.com/autoprefixer
MIT License
21.66k stars 1.26k forks source link

Support print-color-adjust #1454

Closed yisibl closed 2 years ago

yisibl commented 2 years ago

Spec: https://www.w3.org/TR/css-color-adjust-1/#print-color-adjust Caniuse: https://caniuse.com/mdn-css_properties_print-color-adjust

The color-adjust shorthand allows an author to set all of the performance-motivated color adjustment properties in one declaration. (Currently, there is only one such property—print-color-adjust—but more might be added in the future.)

The color-adjust shorthand is currently deprecated. Authors should use the more specific print-color-adjust property, to avoid accidentally resetting performance-based color adjustments in other contexts than the one intended.

lukewarlow commented 2 years ago

Imo that doesn't feel like something that's the job of autoprefixer. Trying to second guess the behaviour developers want sounds like the job of a specific postcss plugin rather than this tool.

Edit this was based on the assumption you meant changing between long and short hands apologies if I've misunderstood.

ai commented 2 years ago

I think @yisibl asks to add -webkit-print-color-adjust for print-color-adjust. Am I right?

yisibl commented 2 years ago

I think @yisibl asks to add -webkit-print-color-adjust for print-color-adjust.

Yes!

ai commented 2 years ago

print-color-adjust was added to caniuse-lite https://github.com/browserslist/caniuse-lite/commit/7228ee1cc76fb0f6c82c303dd781a4e80bb407b8

Now we need to wait caniuse-db to trigger new release of caniuse-lite. Then we will be able to use it in Autoprefixer.

ai commented 2 years ago

Fixed 51b991c

ai commented 2 years ago

The fix was released in 10.4.6

thecrypticace commented 2 years ago

@ai This update causes autoprefixer to generate -moz-print-color-adjust for old versions of FF — however this property does not exist. It should instead output color-adjust for old versions of FF which didn't add support for print-color-adjust until FF 97 which was released in early February this year.

I verified that -moz-print-color-adjust is indeed not a valid property name in newer and older versions of FF:

Screen Shot 2022-05-02 at 09 22 37
ai commented 2 years ago

Adding color-adjust could later trigger Autoprefixer to print a warning? Can we ignore Firefox property?

ai commented 2 years ago

FF ESR needs color-adjust, we need to support it.

ai commented 2 years ago

Fixed 8fe5b66

ai commented 2 years ago

FF fix was released in 10.4.7

Martinspire commented 2 years ago

Why is the warning there for color-adjust to force print-color-adjust? Most implementations I've seen are still using color-adjust so many projects are now getting messages about being deprecated. But because its an external dependency, you don't really want to fix that yourself. But it does show up in a lot of pipelines.

For example, my Angular project now shows me 5 messages about this property in 2 different dependencies. And since I can't override autoprefixer settings, there is now a big pile of text in my browser console before I get to my own project.

I get that you want people to use the new property, but I don't think its time to already show deprecation messages on the color-adjust since that will remain working for a while.

ai commented 2 years ago

Why is the warning there for color-adjust to force print-color-adjust?

Because color-adjust was deprecated.

For example, my Angular project now shows me 5 messages about this property in 2 different dependencies

Open PR in these projects.

And since I can't override autoprefixer settings

You can write custom PostCSS plugin to remove unnecessary warnings from result.warning. But I suggest spending this type on fixing the problem in dependencies.

I get that you want people to use the new property, but I don't think its time to already show deprecation messages on the color-adjust since that will remain working for a while.

It is not the first warning in Autoprefixer about deprecated syntax. https://github.com/postcss/autoprefixer/blob/main/lib/processor.js#L115-L326=