Scoping does not work as expected when using :is and :where selectors in Vue 3.3.9 #9707
Labels
🔨 p3-minor-bug
Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.
scope: compiler
Vue version
3.3.9
Link to minimal reproduction
https://play.vuejs.org/#eNqVVd1uEz0QfZXRXn2gZFf6EBKE8lcEElwAAsQF2hvv7mRj6rWNPZukVH13jr1JkxaKihJF9njG58yZGeeieOl9uR65WBQnsQ3aC0WW0T+rrR68C0JvnKNlcAPVRVlhk7zrorYn1eQPT2yEB2+UMHZEJ51e5wWWKbyarNVkPqmunItZMaHMB+XL79FZ8LhIzvXuINbFgrIl2TL0AouViI+Lqmo7i7COjV6H0rJU1g/VC7hVYbSiB553bnjxoHxQPgZ6lGNzyXGYN8FtIofSB9fhprqYHWFVOFlzmAe2HQcOd8W+EXaMf+PoGocEn9Ava3sJZSS2zi51f0OX1g1eGw4fvGhnr+ujjHGbd9kmYeSrXNoVt2d/sH+P2ymnj4Ezs6P8RYWeZTp+/fk9b7G+OhxcN5pdLW45/MTRmTFxnNxOR9uB9pFfZvs2l1nb/kt8vRW2cZ9UIprVyP65Hq/+kvqBLtQ+UnHXsbf396kKh/7G5h/7G0tqjYrxaV0snauLZ/jdt3r2SAC3TkC+PMq5YUK5PXewlLhhRmWDuAuq7tOpkxUlIynbTXYVmNCynoM53wWSOJKVjpQaxFm2UtL9KsE2qj3rg4P+C/Jj8IafQJuEvNis0IX/HQDvTYjfODiKnlu91K2W8xl1jiNZJ6S8N9g3owCNMxhK0pEbxcMG/KgGJhVpo0F7AcPvLBozHjjo+DuBnCRCeQsSMiXXMAWsGhUTnKWsWiRtUwlT1Q6ZT/wQ3wdmS2NEf9FXeORJ/AOh7LdnBPy39sr90SR9j9yT0OmmTokiJRI0YHiWKBwuX8lg/uKdwYHwJZUKX1SxMTwo0S1x2ZeEkuwZexeljXHeqXA2h9p4t3Kr7Q/Im7EH+NIFWql1ChkcOgPvhgRnyOGpIaP7lVTpilSwAXRry1uF/mPAqJ4p9cACvKdnLQp0aYyWnyX0rLjTUvUo5djMN8P/mx8P58uzn10/Pl+i7k/RDln6lNWum5IA9ybRLoB1XejMpg/qfBIbQ5aqmP4IdkVMg3qnYUOHYNjwexi2u85XnqybzNBb1zml0PQpLn8BGiNv0g==
Steps to reproduce
There is text "foo" with green background and text "bar" with green background.
The associated styles are in Foo.vue component.
What is expected?
The text "foo" is expected to have lightgray background and the text "bar" to have red background, as it have if one use Vue version 3.3.8.
What is actually happening?
There was a pull request #8929 which fixed #8915 but it introduced issues with scoping.
When there is
:is
or:where
selector in a rule, Vue seems to now scope the first selector only.Example 1
:is(.foo, .bar)
-> only.foo
is scopedExample 2
:where(html .foo)
->.foo
is scoped which is expectedExample 3
:where(html) .foo
->html
is scoped instead of.foo
System Info
Any additional comments?
My original use case and how I discovered this behavior was by using a postcss plugin that helps you with setting light or dark theme using a class on
html
element. It allows one to writeprefers-color-scheme: dark
media queries but enable overriding it by using.is-light
and.is-dark
classes on thehtml
element. It has to use:where
pseudo selector in order to not increase the specificity of affected selectors.Here is an example: https://stackblitz.com/edit/github-wm2wq5-fkzdgu?file=app.vue
In the example there is text "foo" which is expected to be green, not red, for prefered theme dark.
The text was updated successfully, but these errors were encountered: