-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
False positive for "Unused CSS selector" #13779
Comments
Here's a minimal version with the same problem. The CSS selectors are valid and shouldn't be considered unused https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE32OwQqDMBBEfyXsqbWW3EMq9DuaHjSuGBqTYFapiP9eVqHQSy_Lzuy8ZVbonMcM6rFCqAcEBfeUoARaEos8oyeEEnKcRsuO9nWDvjLBkHYhTSQ4ejNge7SvJr4NCHmcc6pD1Tst98UELb9s0JkWj3tuN1Vf55Pqop3ydXbZNR7PgjmxcsaQjT6OasSW5cYvDMmC597iFxWX_ywVkuscHaCEIbauc9iConHC7bl9AAR1ZH0YAQAA |
These feel like two related although potentially distinct issues that we need to make sure are both addressed. One is about |
Seems broken for regular element selectors as well ( |
Found the same issue, I reported in #13717 as well - might be helpful as Simon was working on a fix for a relevant one yesterday. TLDR current test cases for :has as of 5.0.5 has not covered this particular one yet: Input: <x>
<y></y>
<w></w>
</x>
<style>
x:has(y) w {
color: green;
}
</style> Expected: x.svelte-xyz:has(y:where(.svelte-xyz)) w:where(.svelte-xyz) {
color: green;
} |
Just came here to say that this issue appeared in This is my minimal reproduction: https://svelte.dev/playground/23060df7688c4bb1be84023e56f00996?version=5.0.5 |
I have raised the PR to fix the issue in internal compiler code. I hope some one will review the PR and will provide approval for go ahead. |
I resisted this previously because it felt a bit wasteful, but I now think that there's really no way around this: Instead of only going upwards the tree while matching, for `:has` we go _down_ the tree to see what matches. More specifically, we're collecting the children of the current element and then check if one of those does match the selectors inside `:has`. This makes the way the code works easier to reason about and also removes some boolean tracking we had to add for the previous approach. Fixes #13779
I resisted this previously because it felt a bit wasteful, but I now think that there's really no way around this: Instead of only going upwards the tree while matching, for `:has` we go _down_ the tree to see what matches. More specifically, we're collecting the children of the current element and then check if one of those does match the selectors inside `:has`. This makes the way the code works easier to reason about and also removes some boolean tracking we had to add for the previous approach. Fixes #13779
Describe the bug
After the upgrade to the stable v5 I'm now getting a few of these false positives, which seem related to the use of the
:has()
pseudo-class in CSS rules, possibly in conjunction with the shorthand class (.copied
in this repro's case).Reproduction
https://svelte-omnisite.vercel.app/playground/hello-world?version=5.0.5#H4sIAAAAAAAAE41V224jNwz9FWa2i9iox7FRBC1mHRfFtm99KtKnusDKEscmohEVifKlrv-90FxsdxMUfbAxosijw3OomVNRk8VYVH-cCjl6LKo2UEwKp5q8-sn7adyhlRxbq4jvxTU7QSexqIpF1IG8gFVu87QqJK6K5coBaHZRgJP4JPAEX37lgA2Qj6kBw5YDRBJQDcqkzUUtKCmAMuQpanIbQEsygYgGDANSig0bEGw8ByCnyZBJTiDlw9ccEFA6aIRGbZwCZek1qSn8LoCOGlAGGsoPO3Skmgm8JorgOEpIBvCAQZMoIXaQrFWN5g45J1GkfFILSR7wAKhAc9Ow4a6B16RkCj9nSJUEgUIK2PdKDgL6gFt0BgNJDuzYJi9KEHa5U8AYETRZOyiEgAnqtCEl4DIh8CqQkhSm8MtBoxdMWUYnwFor1EpAJ09GSa5gBz4wGXRZxawUOdDJepX7Bq5r0qTAYMSQdxu2mYbKApEBjL2uqZl--ZQttSgg1CC3jn4TM_fRGFSE37J17vnocZGHimuIKM9d6hL-btl_uk6FZk9oMkYWY4dmdHfXA4_btDo53dqg2R9HYzjlIIC2qEIPO-oL7roKAKd2tFHCYaot-TWrYKb7QILPeJBRN4hD7rWLK8_RaAxPSxhd9zLr8QS-n826uvPKLR66cV-u3MotfMDlqUM-L9ZJJDO2Ksaq7zCL8bQquq1VAey0Jf3ydMp9nSG7WVq1Rvu0Kj6zP66K5eKhy14uHjL8yi2iV2556hF_hPvP7dPdPVRw_znDgTDk6vvz4qFNbslFOVpsr6IPOCjYkCv3ZGRbwXyGTS9How5D9PEa5R2G2vK-PFYQdeDewpweNuQqmPVrr4wht6lgfqld86GMW2V4X8GjP7S_-cwf4Dt_gA9a6z5vvyXBMnqlsco8y31QfoDlSHkIKgholdAOBxeGppbQi376ukKtI9skOPjN_ko30GYr1-WaRbi5ri3WN7u9LORISNlLSTAYqnzFhhPWSr9sAidnSp3vbgUfZrPZgCJBuY5aaVJQHcfZdB7f7vvAHoMcqzeQkzZiAvuyJisY3hYLNeQ25XB9KkAVsSTXZ-oUYqbmmdxQ_46c1TZbP_k6PO1H8PRfHf9wo8cN1QrWNoXR3B_G_5c1J7klmAd7ONpQ9FZliSzrlzfj8p7589nHf_n7eFm3RGoOTdU92vxWKx9nHyeQ_we-Q491XfeRmp2Ukf7C28Fvg3vsRmzN1gyXyStN2dXLpek8KHGXP6Q3s3Q1pPMBvm17n1yCKo56K8b93qDL5ZD5zfuqfw0Uk0LwIEUlIeH5z_M_1kgWcgkIAAA=
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: