-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from yandex/fix_empty_comments_at_rule_creation
Fix empty comments at rule copy
- Loading branch information
Showing
3 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
packages/postcss-logical-fallback/src/utils/has-empty-child-nodes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
38
packages/postcss-logical-fallback/tests/no-changes.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |