File tree Expand file tree Collapse file tree 6 files changed +103
-2
lines changed
Expand file tree Collapse file tree 6 files changed +103
-2
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## [ 4.0.4] - 2023-04-08
4+
5+ - Fixed unwanted removal of empty rules
6+
37## [ 4.0.3] - 2023-03-04
48
59- Fixed a bug releated to overriden properties
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ function postcssRTLCSS (options: PluginOptions = {}): Plugin {
2424 clean ( css ) ;
2525 }
2626 } ) ;
27- } ;
27+ }
2828
2929postcssRTLCSS . postcss = true ;
3030
Original file line number Diff line number Diff line change @@ -58,7 +58,9 @@ export const clean = (css: Container): void => {
5858 ! ! ( node as Container ) . nodes
5959 ) {
6060 if ( ! ruleHasChildren ( node as Container ) ) {
61- node . remove ( ) ;
61+ if ( mode === Mode . diff ) {
62+ node . remove ( ) ;
63+ }
6264 } else {
6365 const prev = node . prev ( ) ;
6466 if ( prev ) {
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` [[Mode: combined]] Empty Rules Tests: Basic 1` ] = `
4+ ".test1 { }
5+
6+ .test2, .test3 { }
7+
8+ [dir="ltr"] .test4 {
9+ text - align : left ;
10+ }
11+
12+ [dir="rtl"] .test4 {
13+ text - align : right ;
14+ }
15+
16+ .test5 {
17+ color : red ;
18+ }
19+
20+ [dir="ltr"] .test5 {
21+ padding - left : 20px ;
22+ }
23+
24+ [dir="rtl"] .test5 {
25+ padding - right : 20px ;
26+ } "
27+ ` ;
28+
29+ exports [` [[Mode: diff]] Empty Rules Tests: Basic 1` ] = `
30+ ".test4 {
31+ text - align : right ;
32+ }
33+
34+ .test5 {
35+ padding - left : 0 ;
36+ padding - right : 20px ;
37+ } "
38+ ` ;
39+
40+ exports [` [[Mode: override]] Empty Rules Tests: Basic 1` ] = `
41+ ".test1 { }
42+
43+ .test2, .test3 { }
44+
45+ .test4 {
46+ text - align : left ;
47+ }
48+
49+ [dir="rtl"] .test4 {
50+ text - align : right ;
51+ }
52+
53+ .test5 {
54+ color : red ;
55+ padding - left : 20px ;
56+ }
57+
58+ [dir="rtl"] .test5 {
59+ padding - left : 0 ;
60+ padding - right : 20px ;
61+ } "
62+ ` ;
Original file line number Diff line number Diff line change 1+ .test1 {}
2+
3+ .test2 , .test3 {}
4+
5+ .test4 {
6+ text-align : left;
7+ }
8+
9+ .test5 {
10+ color : red;
11+ padding-left : 20px ;
12+ }
Original file line number Diff line number Diff line change 1+ import postcss from 'postcss' ;
2+ import postcssRTLCSS from '../src' ;
3+ import { PluginOptions } from '../src/@types' ;
4+ import { readCSSFile , runTests } from './utils' ;
5+
6+ runTests ( { } , ( pluginOptions : PluginOptions ) : void => {
7+ describe ( `[[Mode: ${ pluginOptions . mode } ]] Empty Rules Tests: ` , ( ) => {
8+ let input = '' ;
9+
10+ beforeEach ( async ( ) : Promise < void > => {
11+ input = input || await readCSSFile ( 'empty-rules.css' ) ;
12+ } ) ;
13+
14+ it ( 'Basic' , ( ) : void => {
15+ const options : PluginOptions = { ...pluginOptions } ;
16+ const output = postcss ( [ postcssRTLCSS ( options ) ] ) . process ( input ) ;
17+ expect ( output . css ) . toMatchSnapshot ( ) ;
18+ expect ( output . warnings ( ) ) . toHaveLength ( 0 ) ;
19+ } ) ;
20+ } ) ;
21+ } ) ;
You can’t perform that action at this time.
0 commit comments