Skip to content

Commit 862f951

Browse files
committed
Make aliases affect safe-prefixed rules
1 parent bd5ea0c commit 862f951

16 files changed

+541
-8
lines changed

src/parsers/declarations.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,33 @@ export const parseDeclarations = (
178178
const declPropUnprefixed = vendor.unprefixed(declProp);
179179
const declValue = decl.value.trim();
180180
const declIndexes = Object.keys(declarationHashMap[declProp].indexes).map(Number);
181-
const isAnimation = declPropUnprefixed === ANIMATION_PROP || declPropUnprefixed === ANIMATION_NAME_PROP;
181+
const isAnimation = (
182+
declPropUnprefixed === ANIMATION_PROP ||
183+
declPropUnprefixed === ANIMATION_NAME_PROP ||
184+
aliases[declPropUnprefixed] === ANIMATION_PROP ||
185+
aliases[declPropUnprefixed] === ANIMATION_NAME_PROP
186+
);
182187
const declFlippedProp = declFlipped.prop.trim();
183188
const declFlippedValue = declFlipped.value.trim();
184-
const overridenBy = declarations[declPropUnprefixed];
185-
const hasBeenOverriden = declarationsProps.includes(declPropUnprefixed) || (
186-
overridenBy
187-
? overridenBy.some((d: string): boolean => declarationsProps.indexOf(d) >= 0)
188-
: false
189+
const overridenBy = aliases[declPropUnprefixed]
190+
? declarations[aliases[declPropUnprefixed]]
191+
: declarations[declPropUnprefixed];
192+
const hasBeenOverriden = (
193+
declarationsProps.includes(declPropUnprefixed) ||
194+
declarationsProps.includes(aliases[declPropUnprefixed]) ||
195+
(
196+
overridenBy
197+
? overridenBy.some((d: string): boolean => declarationsProps.indexOf(d) >= 0)
198+
: false
199+
)
189200
);
190-
const overridesPrevious = checkOverrides(declPropUnprefixed, declarationsProps);
201+
const overridesPrevious = aliases[declPropUnprefixed]
202+
? checkOverrides(aliases[declPropUnprefixed], declarationsProps)
203+
: checkOverrides(declPropUnprefixed, declarationsProps);
191204
const isConflictedDeclaration = safeBothPrefix
192-
? !!allDeclarations[declPropUnprefixed]
205+
? aliases[declPropUnprefixed]
206+
? !!(allDeclarations[aliases[declPropUnprefixed]])
207+
: !!(allDeclarations[declPropUnprefixed])
193208
: false;
194209
const sourceDirectiveValue = getSourceDirectiveValue(
195210
controlDirectives,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: combined]] Aliases Tests: without aliases and safeBothPrefix false 1`] = `
4+
".test1 {
5+
view-timeline: --row-a block;
6+
animation-range: cover 0% cover 100%;
7+
animation-timing-function: var(--timing-function);
8+
animation-name: slide-in;
9+
}
10+
11+
[dir="ltr"] .test1 {
12+
transform: translate3d(-21vh, 0, 0);
13+
}
14+
15+
[dir="rtl"] .test1 {
16+
transform: translate3d(21vh, 0, 0);
17+
}
18+
19+
.test2 {
20+
border: 1px solid;
21+
border-color: #FF00FF;
22+
color: white;
23+
custom-border-width: 2px;
24+
}
25+
26+
.test3 {
27+
custom-clip-background: text;
28+
color: rgba(255, 242, 126, 1);
29+
custom-padding: 20px;
30+
}
31+
32+
[dir="ltr"] .test3 {
33+
background: linear-gradient(180deg, #fff27e 0%, #ffffff 100%);
34+
}
35+
36+
[dir="rtl"] .test3 {
37+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
38+
}
39+
40+
[dir] .test3 {
41+
background-position: top;
42+
}"
43+
`;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: combined]] Aliases Tests: without aliases and safeBothPrefix true 1`] = `
4+
".test1 {
5+
view-timeline: --row-a block;
6+
animation-range: cover 0% cover 100%;
7+
}
8+
9+
[dir] .test1 {
10+
animation-timing-function: var(--timing-function);
11+
animation-name: slide-in;
12+
}
13+
14+
[dir="ltr"] .test1 {
15+
transform: translate3d(-21vh, 0, 0);
16+
}
17+
18+
[dir="rtl"] .test1 {
19+
transform: translate3d(21vh, 0, 0);
20+
}
21+
22+
.test2 {
23+
color: white;
24+
custom-border-width: 2px;
25+
}
26+
27+
[dir] .test2 {
28+
border: 1px solid;
29+
border-color: #FF00FF;
30+
}
31+
32+
.test3 {
33+
custom-clip-background: text;
34+
color: rgba(255, 242, 126, 1);
35+
custom-padding: 20px;
36+
}
37+
38+
[dir="ltr"] .test3 {
39+
background: linear-gradient(180deg, #fff27e 0%, #ffffff 100%);
40+
}
41+
42+
[dir="rtl"] .test3 {
43+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
44+
}
45+
46+
[dir] .test3 {
47+
background-position: top;
48+
}"
49+
`;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: combined]] Aliases Tests: with aliases and safeBothPrefix false 1`] = `
4+
".test1 {
5+
view-timeline: --row-a block;
6+
animation-range: cover 0% cover 100%;
7+
animation-timing-function: var(--timing-function);
8+
animation-name: slide-in;
9+
}
10+
11+
[dir="ltr"] .test1 {
12+
transform: translate3d(-21vh, 0, 0);
13+
}
14+
15+
[dir="rtl"] .test1 {
16+
transform: translate3d(21vh, 0, 0);
17+
}
18+
19+
.test2 {
20+
border: 1px solid;
21+
border-color: #FF00FF;
22+
color: white;
23+
custom-border-width: 2px;
24+
}
25+
26+
.test3 {
27+
color: rgba(255, 242, 126, 1);
28+
custom-padding: 20px;
29+
}
30+
31+
[dir="ltr"] .test3 {
32+
background: linear-gradient(180deg, #fff27e 0%, #ffffff 100%);
33+
}
34+
35+
[dir="rtl"] .test3 {
36+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
37+
}
38+
39+
[dir] .test3 {
40+
custom-clip-background: text;
41+
background-position: top;
42+
}"
43+
`;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: combined]] Aliases Tests: with aliases and safeBothPrefix true 1`] = `
4+
".test1 {
5+
animation-range: cover 0% cover 100%;
6+
}
7+
8+
[dir] .test1 {
9+
view-timeline: --row-a block;
10+
animation-timing-function: var(--timing-function);
11+
animation-name: slide-in;
12+
}
13+
14+
[dir="ltr"] .test1 {
15+
transform: translate3d(-21vh, 0, 0);
16+
}
17+
18+
[dir="rtl"] .test1 {
19+
transform: translate3d(21vh, 0, 0);
20+
}
21+
22+
.test2 {
23+
color: white;
24+
}
25+
26+
[dir] .test2 {
27+
border: 1px solid;
28+
border-color: #FF00FF;
29+
custom-border-width: 2px;
30+
}
31+
32+
.test3 {
33+
color: rgba(255, 242, 126, 1);
34+
}
35+
36+
[dir] .test3 {
37+
custom-padding: 20px;
38+
}
39+
40+
[dir="ltr"] .test3 {
41+
background: linear-gradient(180deg, #fff27e 0%, #ffffff 100%);
42+
}
43+
44+
[dir="rtl"] .test3 {
45+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
46+
}
47+
48+
[dir] .test3 {
49+
custom-clip-background: text;
50+
background-position: top;
51+
}"
52+
`;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: diff]] Aliases Tests: without aliases and safeBothPrefix false 1`] = `
4+
".test1 {
5+
transform: translate3d(21vh, 0, 0);
6+
}
7+
8+
.test3 {
9+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
10+
background-position: top;
11+
}"
12+
`;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: diff]] Aliases Tests: without aliases and safeBothPrefix true 1`] = `
4+
".test1 {
5+
transform: translate3d(21vh, 0, 0);
6+
animation-timing-function: var(--timing-function);
7+
animation-name: slide-in;
8+
}
9+
10+
.test2 {
11+
border: 1px solid;
12+
border-color: #FF00FF;
13+
}
14+
15+
.test3 {
16+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
17+
background-position: top;
18+
}"
19+
`;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: diff]] Aliases Tests: with aliases and safeBothPrefix false 1`] = `
4+
".test1 {
5+
transform: translate3d(21vh, 0, 0);
6+
}
7+
8+
.test3 {
9+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
10+
custom-clip-background: text;
11+
background-position: top;
12+
}"
13+
`;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: diff]] Aliases Tests: with aliases and safeBothPrefix true 1`] = `
4+
".test1 {
5+
transform: translate3d(21vh, 0, 0);
6+
view-timeline: --row-a block;
7+
animation-timing-function: var(--timing-function);
8+
animation-name: slide-in;
9+
}
10+
11+
.test2 {
12+
border: 1px solid;
13+
border-color: #FF00FF;
14+
custom-border-width: 2px;
15+
}
16+
17+
.test3 {
18+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
19+
custom-clip-background: text;
20+
background-position: top;
21+
custom-padding: 20px;
22+
}"
23+
`;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`[[Mode: override]] Aliases Tests: without aliases and safeBothPrefix false 1`] = `
4+
".test1 {
5+
transform: translate3d(-21vh, 0, 0);
6+
view-timeline: --row-a block;
7+
animation-range: cover 0% cover 100%;
8+
animation-timing-function: var(--timing-function);
9+
animation-name: slide-in;
10+
}
11+
12+
[dir="rtl"] .test1 {
13+
transform: translate3d(21vh, 0, 0);
14+
}
15+
16+
.test2 {
17+
border: 1px solid;
18+
border-color: #FF00FF;
19+
color: white;
20+
custom-border-width: 2px;
21+
}
22+
23+
.test3 {
24+
background: linear-gradient(180deg, #fff27e 0%, #ffffff 100%);
25+
custom-clip-background: text;
26+
color: rgba(255, 242, 126, 1);
27+
custom-padding: 20px;
28+
}
29+
30+
[dir="rtl"] .test3 {
31+
background: linear-gradient(-180deg, #fff27e 0%, #ffffff 100%);
32+
}
33+
34+
[dir] .test3 {
35+
background-position: top;
36+
}"
37+
`;

0 commit comments

Comments
 (0)