Skip to content

Commit

Permalink
Merge pull request #6 from yandex/fix_empty_comments_at_rule_creation
Browse files Browse the repository at this point in the history
Fix empty comments at rule copy
  • Loading branch information
alexey-ershkov authored Oct 8, 2024
2 parents 09432fd + c5b9e18 commit ce6eb7d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/postcss-logical-fallback/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-logical-fallback",
"version": "1.0.1",
"version": "1.0.2",
"description": "PostCSS plugin for logical fallback props",
"main": "index.js",
"files": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {Container} from "postcss";
import { Container } from 'postcss';

export const hasEmptyChildNodes = ({nodes}: Container) => !nodes || nodes.length === 0
export const hasEmptyChildNodes = ({ nodes }: Container) => {
const significantNodes = nodes.filter((node) => node.type !== 'comment');
return !significantNodes || significantNodes.length === 0;
};
38 changes: 38 additions & 0 deletions packages/postcss-logical-fallback/tests/no-changes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { test } from 'uvu';
import { run } from './run';

test('should not copy comments', async () => {
await run(
`body {
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
min-height: 100vh;
padding: 2rem;
}`,
`body {
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
min-height: 100vh;
padding: 2rem;
}`,
);

await run(
`.class {
/*
multiline
comment
*/
min-height: 100vh;
padding: 2rem;
}`,
`.class {
/*
multiline
comment
*/
min-height: 100vh;
padding: 2rem;
}`,
);
});

test.run();

0 comments on commit ce6eb7d

Please sign in to comment.