`::placeholder` gets incorrectly turned into `:placeholder-shown`
Copied from https://github.com/vitejs/vite/issues/23570.
Vite pointed me towards this repo as the potential source of this bug.
Describe the bug
We recently updated to Vite 8, and we encountered an issue with the CSS minification engine. When running a build command, any CSS that targets ::placeholder will incorrectly be changed to also target :placeholder-shown. This is a problem, because we want to modify styles of the placeholder that the browser shows, but after the build the whole input element is changed.
Test case
See linked repo for a full reproduction of the bug
custom-input {
input,
textarea {
background-color: blue;
&:focus,
&:active {
background-color: red;
border-bottom-width: 2px;
&::placeholder {
visibility: hidden;
}
}
}
}Command ran
bun run buildPlease note that this issue does not show up when using the dev server, only when doing build
Expected result
The output styles target the input field, the focus state, and the placeholder
Actual result
The output styles target the input field, the focus state, the placeholder, and ::placeholder-shown
Reproduction
https://github.com/draganczukp/placeholder-test
Steps to reproduce
Run npm run build or bun run build
The issue will NOT show on the dev server
System Info
System:
OS: Linux 6.8 Ubuntu 24.04.5 LTS 24.04.5 LTS (Noble Numbat)
CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-1370P
Memory: 6.18 GB / 31.03 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 22.21.1 - /run/user/1000/fnm_multishells/441686_1790240402547/bin/node
npm: 10.9.4 - /run/user/1000/fnm_multishells/441686_1790240402547/bin/npm
bun: 1.4.0 - /home/REDACTED/.bun/bin/bun
Browsers:
Chrome: 153.0.8010.36
Firefox: 156.0
Firefox Developer Edition: 156.0
npmPackages:
vite: ^8.3.0 => 8.3.0Used Package Manager
bun
Source: parcel-bundler/lightningcss