Skip to content

Commit 280e4c0

Browse files
committed
In the override method change the unset value to override properties by the intial value of them
1 parent 7742e25 commit 280e4c0

13 files changed

+277
-151
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [1.6.3 - 1.6.4] - 2021-02-19
4+
5+
- In the override method change the `unset` value to override properties by the intial value of them to support the override method in Internet Explorer
6+
7+
## [1.6.2] - 2020-12-16
8+
9+
- Updated packages to the latest versions and solved vulnerabilities
10+
- Some minor changes in the README file
11+
312
## [1.6.1] - 2020-08-18
413

514
- Updated multiple packages

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ This is the alternative method, it will generate less code because it lets the m
164164

165165
[dir="rtl"] .test1, [dir="rtl"] .test2 {
166166
border-radius: 2px 0 8px 0;
167-
padding-right: unset;
167+
padding-right: 0;
168168
padding-left: 20px;
169169
text-align: right;
170170
transform: translate(50%, 50%);
@@ -241,7 +241,7 @@ However, using the override method the generated code will be the next one:
241241
}
242242
243243
[dir="rtl"] .test2 {
244-
padding-right: unset;
244+
padding-right: 0;
245245
padding-left: 10px;
246246
}
247247
```
@@ -622,7 +622,7 @@ const options = {
622622
}
623623
624624
[dir="ltr"] .test1, [dir="ltr"] .test2 {
625-
left: unset;
625+
left: auto;
626626
right: 10px;
627627
}
628628
```

index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-rtlcss",
3-
"version": "1.6.1",
3+
"version": "1.6.5",
44
"description": "PostCSS plugin to build Cascading Style Sheets (CSS) with Left-To-Right (LTR) and Right-To-Left (RTL) rules",
55
"keywords": [
66
"postcss",

src/data/initial-values.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"0": [
3+
"border-bottom-right-radius",
4+
"border-bottom-left-radius",
5+
"border-end-end-radius",
6+
"border-end-start-radius",
7+
"border-start-end-radius",
8+
"border-start-start-radius",
9+
"border-top-left-radius",
10+
"border-top-right-radius",
11+
"margin-block-end",
12+
"margin-block-start",
13+
"margin-top",
14+
"margin-right",
15+
"margin-bottom",
16+
"margin-left",
17+
"margin-inline-end",
18+
"margin-inline-start",
19+
"padding-block-end",
20+
"padding-block-start",
21+
"padding-top",
22+
"padding-right",
23+
"padding-bottom",
24+
"padding-left",
25+
"padding-inline-end",
26+
"padding-inline-start",
27+
"scroll-margin-block-end",
28+
"scroll-margin-block-start",
29+
"scroll-margin-top",
30+
"scroll-margin-right",
31+
"scroll-margin-bottom",
32+
"scroll-margin-left",
33+
"scroll-margin-inline-end",
34+
"scroll-margin-inline-start"
35+
],
36+
"auto": [
37+
"top",
38+
"right",
39+
"bottom",
40+
"left",
41+
"grid-column-end",
42+
"grid-column-start",
43+
"grid-row-end",
44+
"grid-row-start",
45+
"inset-block-end",
46+
"inset-block-start",
47+
"inset-inline-end",
48+
"inset-inline-start",
49+
"scroll-padding-block-end",
50+
"scroll-padding-block-start",
51+
"scroll-padding-top",
52+
"scroll-padding-right",
53+
"scroll-padding-bottom",
54+
"scroll-padding-left",
55+
"scroll-padding-inline-end",
56+
"scroll-padding-inline-start"
57+
],
58+
"currentcolor": [
59+
"border-block-start-color",
60+
"border-block-end-color",
61+
"border-top-color",
62+
"border-right-color",
63+
"border-bottom-color",
64+
"border-left-color",
65+
"border-inline-start-color",
66+
"border-inline-end-color"
67+
],
68+
"medium": [
69+
"border-block-start-width",
70+
"border-block-end-width",
71+
"border-top-width",
72+
"border-right-width",
73+
"border-bottom-width",
74+
"border-left-width",
75+
"border-inline-start-width",
76+
"border-inline-end-width"
77+
],
78+
"none": [
79+
"border-block-start",
80+
"border-block-end",
81+
"border-top",
82+
"border-right",
83+
"border-bottom",
84+
"border-left",
85+
"border-top-style",
86+
"border-right-style",
87+
"border-bottom-style",
88+
"border-left-style",
89+
"border-block-start-style",
90+
"border-block-end-style",
91+
"border-inline-start",
92+
"border-inline-end",
93+
"border-inline-start-style",
94+
"border-inline-end-style"
95+
]
96+
}

src/parsers/declarations.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { store } from '@data/store';
1212
import { addSelectorPrefixes } from '@utilities/selectors';
1313
import { isIgnoreDirectiveInsideAnIgnoreBlock, checkDirective } from '@utilities/directives';
14-
import { declarations, allDeclarations, appendDeclarationToRule, hasIgnoreDirectiveInRaws } from '@utilities/declarations';
14+
import { declarations, allDeclarations, initialValues, appendDeclarationToRule, hasIgnoreDirectiveInRaws } from '@utilities/declarations';
1515
import { walkContainer } from '@utilities/containers';
1616
import { cleanRuleRawsBefore } from '@utilities/rules';
1717

@@ -200,7 +200,8 @@ export const parseDeclarations = (rule: Rule, autorenamed = false): void => {
200200
} else {
201201
if (FLIP_PROPERTY_REGEXP.test(decl.prop) && !declarationHashMap[declFlipped.prop]) {
202202
const declClone = decl.clone();
203-
declClone.value = 'unset';
203+
/* istanbul ignore next */
204+
declClone.value = initialValues[decl.prop] || 'unset';
204205
ruleFlipped.append(declClone);
205206
}
206207
if (isConflictedDeclaration && !hasIgnoreDirectiveInRaws(decl)) {

src/utilities/declarations.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import { ObjectWithProps, DeclarationsData } from '@types';
33
import { COMMENT_TYPE, RTL_COMMENT_IGNORE_REGEXP } from '@constants';
44
import shorthandDeclarationsJson from '@data/shorthand-declarations.json';
55
import notShorthandDeclarationsJson from '@data/not-shorthand-declarations.json';
6+
import initialValuesJson from '@data/initial-values.json';
67

78
const declarationsData: DeclarationsData = shorthandDeclarationsJson;
89
const notShorthandDeclarationsArray: string[] = notShorthandDeclarationsJson;
10+
const initialValuesData: ObjectWithProps<string[]> = initialValuesJson;
911
const declarations: ObjectWithProps<string[]> = {};
1012
const allDeclarations: ObjectWithProps<string[]> = {};
13+
const initialValues: ObjectWithProps<string> = {};
1114

1215
const getOverrideTree = (prop: string): string[] => {
1316
const overridenProp = declarationsData[prop].overridden;
@@ -29,6 +32,12 @@ notShorthandDeclarationsArray.forEach((declaration: string): void => {
2932
allDeclarations[declaration] = [];
3033
});
3134

35+
Object.keys(initialValuesData).forEach((value: string): void => {
36+
initialValuesData[value].forEach((prop: string): void => {
37+
initialValues[prop] = value;
38+
});
39+
});
40+
3241
const appendDeclarationToRule = (decl: Declaration, rule: Rule): void => {
3342
const declClone = decl.clone();
3443
const declPrev = decl.prev();
@@ -52,6 +61,7 @@ const hasIgnoreDirectiveInRaws = (decl: Declaration): boolean => {
5261
export {
5362
declarations,
5463
allDeclarations,
64+
initialValues,
5565
appendDeclarationToRule,
5666
hasIgnoreDirectiveInRaws
5767
};

0 commit comments

Comments
 (0)