diff --git a/.changeset/fuzzy-donuts-wonder.md b/.changeset/fuzzy-donuts-wonder.md new file mode 100644 index 000000000..b31023913 --- /dev/null +++ b/.changeset/fuzzy-donuts-wonder.md @@ -0,0 +1,9 @@ +--- +'astro': patch +--- + +**BREAKING** Implement [RFC0012](https://github.com/withastro/rfcs/blob/main/proposals/0012-scoped-css-with-preserved-specificity.md) to preserve authored specificity for Astro scoped styles. + +If you use a mix of global styles and Astro scoped styles, **please visually inspect your site** after upgrading to confirm that styles are working as expected. + +If you previously relied on Astro's scoped styles to increase the specificity of your selectors, please update your selectors to use an additional class. For example, updating `div` to `div.my-class` will match the previous behavior. diff --git a/packages/astro/package.json b/packages/astro/package.json index 3e1e13fec..c8f631217 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -82,7 +82,7 @@ "test:e2e:match": "playwright test -g" }, "dependencies": { - "@astrojs/compiler": "^0.21.0", + "@astrojs/compiler": "^0.22.0", "@astrojs/language-server": "^0.20.0", "@astrojs/markdown-remark": "^0.12.0", "@astrojs/prism": "0.6.1", diff --git a/packages/astro/test/0-css.test.js b/packages/astro/test/0-css.test.js index 4b2862470..7d7000584 100644 --- a/packages/astro/test/0-css.test.js +++ b/packages/astro/test/0-css.test.js @@ -46,7 +46,7 @@ describe('CSS', function () { expect(el2.attr('class')).to.equal(`visible ${scopedClass}`); // 2. check CSS - const expected = `.blue.${scopedClass}{color:#b0e0e6}.color\\\\:blue.${scopedClass}{color:#b0e0e6}.visible.${scopedClass}{display:block}`; + const expected = `.blue:where(.${scopedClass}){color:#b0e0e6}.color\\\\:blue:where(.${scopedClass}){color:#b0e0e6}.visible:where(.${scopedClass}){display:block}`; expect(bundledCSS).to.include(expected); }); @@ -69,11 +69,11 @@ describe('CSS', function () { }); it('