postcss / autoprefixer

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

[10.4.7] The `color-adjust` shorthand is currently deprecated #1471

Closed julien-deramond closed 1 year ago

julien-deramond commented 1 year ago

I've seen that other issues were filled out regarding print-color-adjust/color-adjust but I haven't found an answer to this problem. Feel free to close it if you think this can be considered as duplicate.

The next steps are done with the same environment:

npm ls | grep postcss
└── postcss-cli@10.0.0

Autoprefixer 10.4.7

npm ls | grep autoprefixer
├── autoprefixer@10.4.7

Let's consider the following example:

.example {
    print-color-adjust: exact;
}

Empty browserslist

 $ npx postcss *.css --use autoprefixer
.example {
    print-color-adjust: exact;
}

Nothing changes in the CSS file.

browserslist from Bootstrap

At Bootstrap, our browserslist is the following:

"browserslist": [
    "last 2 major versions",
    "not dead",
    "Chrome >= 60",
    "Firefox >= 60",
    "Firefox ESR",
    "iOS >= 12",
    "Safari >= 12",
    "not Explorer <= 11"
  ]
 $ npx postcss *.css --use autoprefixer
.example {
    -webkit-print-color-adjust: exact;
       color-adjust: exact;
            print-color-adjust: exact;
}

In this case, color-adjust and -webkit-print-color-adjust are added.

browserslist from Bootstrap without Firefox rules

If we remove the Firefox rules from browserslist:

"browserslist": [
    "last 2 major versions",
    "not dead",
    "Chrome >= 60",
    "iOS >= 12",
    "Safari >= 12",
    "not Explorer <= 11"
  ]
 $ npx postcss *.css --use autoprefixer
.example {
    -webkit-print-color-adjust: exact;
            print-color-adjust: exact;
}

Only -webkit-print-color-adjust is added.

Autoprefixer 10.4.6 and 10.4.5

If I repeat the process with our complete browserslist and different recent versions of autoprefixer:

Problem

Based on those tests, we know that only 10.4.7 adds color-adjust depending on the versions of Firefox in browserslist (color-adjust seems to be added when Firefox > 97 rule is here).

Now let's follow this use case:

  1. Create a test.css that contains:
.example {
    print-color-adjust: exact;
}
  1. Launch npx postcss *.css --use autoprefixer and copy the content in our test.css that now contains:

    .example {
    -webkit-print-color-adjust: exact;
       color-adjust: exact;
            print-color-adjust: exact;
    }
  2. Re-launch npx postcss *.css --use autoprefixer

.example {
    -webkit-print-color-adjust: exact;
       color-adjust: exact;
            print-color-adjust: exact;
}

3:8 ⚠  Replace color-adjust to print-color-adjust. The color-adjust shorthand is currently deprecated. [autoprefixer]

A warning message appears ⚠ Replace color-adjust to print-color-adjust. The color-adjust shorthand is currently deprecated. [autoprefixer].

IDK if this is a bug or something in my usage that's not correct but it's a problem somehow that in one hand autoprefixer adds color-adjust based on the content of browserslist and on the other hand (when launched agains its own results) consider the result of its own modification as deprecated.

ai commented 1 year ago

Hi. Thanks for the issue with many details.

What do you think if we will not print warning if rule also contains print-color-adjust? 9b670b4

julien-deramond commented 1 year ago

Based on the use cases I'm aware of, that should do it yeah.

ai commented 1 year ago

Released in 10.4.8