Handle feedback from #14783 (#14788)

This PR is a continuation of #14783 to handle the feedback on that PR.

1. Update the test to be more realistic
2. Updated the comment

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
This commit is contained in:
Robin Malfait 2024-10-24 22:11:59 +02:00 • committed by GitHub
parent 1eab49d0b1
commit f83041852d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View file

@ -1560,7 +1560,7 @@ test(
`,
'tailwind.config.js': js`module.exports = {}`,
'src/index.css': css`
@import 'tailwindcss/utilities';
@import 'tailwindcss/components';
/* No layer expected */
@import './my-components.css';
@ -1571,7 +1571,7 @@ test(
/* Expecting a layer */
@import './my-other.css';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
`,
'src/my-components.css': css`
@layer components {
@ -1600,8 +1600,6 @@ test(
expect(await fs.dumpFiles('./src/**/*.css')).toMatchInlineSnapshot(`
"
--- ./src/index.css ---
@import 'tailwindcss/utilities' layer(utilities);
/* No layer expected */
@import './my-components.css';
@ -1609,7 +1607,9 @@ test(
@import './my-utilities.css';
/* Expecting a layer */
@import './my-other.css' layer(utilities);
@import './my-other.css' layer(components);
@import 'tailwindcss/utilities' layer(utilities);
--- ./src/my-components.css ---
@utility foo {

View file

@ -158,8 +158,8 @@ async function run() {
)
if (!importedSheet) continue
// Only remove the `layer(…)` next to the import, if any of the children
// contains an `@utility`. Otherwise the `@utility` will not be top-level.
// Only remove the `layer(…)` next to the import if any of the children
// contain `@utility`. Otherwise `@utility` will not be top-level.
if (
!importedSheet.containsRule((node) => node.type === 'atrule' && node.name === 'utility')
) {